Skip to content

Commit 45259b5

Browse files
committed
Auto merge of #148376 - jhpratt:rollup-tfn2bbb, r=jhpratt
Rollup of 12 pull requests Successful merges: - #147137 (Mention crate being analyzed in query description) - #147642 (Miscellaneous const-generics-related fixes) - #147806 (Ignore test-dashboard related files) - #147947 (Implement `strip_circumfix` lib feature) - #148194 (compiletest: Remove `cleanup_debug_info_options`) - #148199 (compiletest: Don't modify `testpaths` when creating aux contexts) - #148247 (Remove two special cases from reachable_non_generics) - #148348 (dangling ptr lint cleanup) - #148357 (temporary-lifetime-extension.rs test works in all editions) - #148362 (docs: makes a note about possible building `rustc 1.91.0 + host tools` for win7) - #148367 (Use --print host-tuple to get the host) - #148374 (miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bd3ac03 + ebc6b6a commit 45259b5

File tree

526 files changed

+625
-1660
lines changed

Some content is hidden

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

526 files changed

+625
-1660
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ node_modules
9090
## Rustdoc GUI tests
9191
tests/rustdoc-gui/src/**.lock
9292

93+
## Test dashboard
94+
.citool-cache/
95+
test-dashboard/
96+
9397
## direnv
9498
/.envrc
9599
/.direnv/

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
5151
return Default::default();
5252
}
5353

54-
// Check to see if this crate is a "special runtime crate". These
55-
// crates, implementation details of the standard library, typically
56-
// have a bunch of `pub extern` and `#[no_mangle]` functions as the
57-
// ABI between them. We don't want their symbols to have a `C`
58-
// export level, however, as they're just implementation details.
59-
// Down below we'll hardwire all of the symbols to the `Rust` export
60-
// level instead.
61-
let special_runtime_crate =
62-
tcx.is_panic_runtime(LOCAL_CRATE) || tcx.is_compiler_builtins(LOCAL_CRATE);
54+
let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE);
6355

6456
let mut reachable_non_generics: DefIdMap<_> = tcx
6557
.reachable_set(())
@@ -104,11 +96,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
10496
if tcx.cross_crate_inlinable(def_id) { None } else { Some(def_id) }
10597
})
10698
.map(|def_id| {
107-
// We won't link right if this symbol is stripped during LTO.
108-
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name;
109-
let used = name == "rust_eh_personality";
110-
111-
let export_level = if special_runtime_crate {
99+
let export_level = if is_compiler_builtins {
100+
// We don't want to export compiler-builtins symbols from any
101+
// dylibs, even rust dylibs. Unlike all other crates it gets
102+
// duplicated in every linker invocation and it may otherwise
103+
// unintentionally override definitions of these symbols by
104+
// libgcc or compiler-rt for C code.
112105
SymbolExportLevel::Rust
113106
} else {
114107
symbol_export_level(tcx, def_id.to_def_id())
@@ -131,8 +124,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
131124
SymbolExportKind::Text
132125
},
133126
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
134-
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
135-
|| used,
127+
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER),
136128
rustc_std_internal_symbol: codegen_attrs
137129
.flags
138130
.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL),

compiler/rustc_hir_analysis/src/collect/generics_of.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
7777
// stable enough and does not need a feature gate anymore.
7878
Node::AnonConst(_) => {
7979
let parent_did = tcx.parent(def_id.to_def_id());
80-
81-
// We don't do this unconditionally because the `DefId` parent of an anon const
82-
// might be an implicitly created closure during `async fn` desugaring. This would
83-
// have the wrong generics.
84-
//
85-
// i.e. `async fn foo<'a>() { let a = [(); { 1 + 2 }]; bar().await() }`
86-
// would implicitly have a closure in its body that would be the parent of
87-
// the `{ 1 + 2 }` anon const. This closure's generics is simply a witness
88-
// instead of `['a]`.
89-
let parent_did = if let DefKind::AnonConst = tcx.def_kind(parent_did) {
90-
parent_did
91-
} else {
92-
tcx.hir_get_parent_item(hir_id).to_def_id()
93-
};
9480
debug!(?parent_did);
9581

9682
let mut in_param_ty = false;

compiler/rustc_lint/messages.ftl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ lint_confusable_identifier_pair = found both `{$existing_sym}` and `{$sym}` as i
193193
.current_use = this identifier can be confused with `{$existing_sym}`
194194
.other_use = other identifier used here
195195
196-
lint_dangling_pointers_from_locals = a dangling pointer will be produced because the local variable `{$local_var_name}` will be dropped
197-
.ret_ty = return type of the {$fn_kind} is `{$ret_ty}`
198-
.local_var = `{$local_var_name}` is part the {$fn_kind} and will be dropped at the end of the {$fn_kind}
196+
lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`
197+
.ret_ty = return type is `{$ret_ty}`
198+
.local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}
199199
.created_at = dangling pointer created here
200-
.note = pointers do not have a lifetime; after returning, the `{$local_var_ty}` will be deallocated at the end of the {$fn_kind} because nothing is referencing it as far as the type system is concerned
200+
.note = a dangling pointer is safe, but dereferencing one is undefined behavior
201201
202202
lint_dangling_pointers_from_temporaries = a dangling pointer will be produced because the temporary `{$ty}` will be dropped
203203
.label_ptr = this pointer will immediately be invalid

compiler/rustc_middle/src/query/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ rustc_queries! {
397397
/// The root query triggering all analysis passes like typeck or borrowck.
398398
query analysis(key: ()) {
399399
eval_always
400-
desc { "running analysis passes on this crate" }
400+
desc { |tcx|
401+
"running analysis passes on crate `{}`",
402+
tcx.crate_name(LOCAL_CRATE),
403+
}
401404
}
402405

403406
/// This query checks the fulfillment of collected lint expectations.

compiler/rustc_mir_build/src/thir/constant.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ pub(crate) fn lit_to_const<'tcx>(
5858
(ast::LitKind::Byte(n), ty::Uint(ty::UintTy::U8)) => {
5959
ty::ValTree::from_scalar_int(tcx, n.into())
6060
}
61-
(ast::LitKind::CStr(byte_sym, _), ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::CStr)) => {
62-
ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str())
61+
(ast::LitKind::CStr(byte_sym, _), ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::CStr)) =>
62+
{
63+
// A CStr is a newtype around a byte slice, so we create the inner slice here.
64+
// We need a branch for each "level" of the data structure.
65+
let bytes = ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str());
66+
ty::ValTree::from_branches(tcx, [bytes])
6367
}
6468
(ast::LitKind::Int(n, _), ty::Uint(ui)) if !neg => {
6569
let scalar_int = trunc(n.get(), *ui);

library/core/src/slice/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,38 @@ impl<T> [T] {
27252725
None
27262726
}
27272727

2728+
/// Returns a subslice with the prefix and suffix removed.
2729+
///
2730+
/// If the slice starts with `prefix` and ends with `suffix`, returns the subslice after the
2731+
/// prefix and before the suffix, wrapped in `Some`.
2732+
///
2733+
/// If the slice does not start with `prefix` or does not end with `suffix`, returns `None`.
2734+
///
2735+
/// # Examples
2736+
///
2737+
/// ```
2738+
/// #![feature(strip_circumfix)]
2739+
///
2740+
/// let v = &[10, 50, 40, 30];
2741+
/// assert_eq!(v.strip_circumfix(&[10], &[30]), Some(&[50, 40][..]));
2742+
/// assert_eq!(v.strip_circumfix(&[10], &[40, 30]), Some(&[50][..]));
2743+
/// assert_eq!(v.strip_circumfix(&[10, 50], &[40, 30]), Some(&[][..]));
2744+
/// assert_eq!(v.strip_circumfix(&[50], &[30]), None);
2745+
/// assert_eq!(v.strip_circumfix(&[10], &[40]), None);
2746+
/// assert_eq!(v.strip_circumfix(&[], &[40, 30]), Some(&[10, 50][..]));
2747+
/// assert_eq!(v.strip_circumfix(&[10, 50], &[]), Some(&[40, 30][..]));
2748+
/// ```
2749+
#[must_use = "returns the subslice without modifying the original"]
2750+
#[unstable(feature = "strip_circumfix", issue = "147946")]
2751+
pub fn strip_circumfix<S, P>(&self, prefix: &P, suffix: &S) -> Option<&[T]>
2752+
where
2753+
T: PartialEq,
2754+
S: SlicePattern<Item = T> + ?Sized,
2755+
P: SlicePattern<Item = T> + ?Sized,
2756+
{
2757+
self.strip_prefix(prefix)?.strip_suffix(suffix)
2758+
}
2759+
27282760
/// Returns a subslice with the optional prefix removed.
27292761
///
27302762
/// If the slice starts with `prefix`, returns the subslice after the prefix. If `prefix`

library/core/src/str/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,42 @@ impl str {
24472447
suffix.strip_suffix_of(self)
24482448
}
24492449

2450+
/// Returns a string slice with the prefix and suffix removed.
2451+
///
2452+
/// If the string starts with the pattern `prefix` and ends with the pattern `suffix`, returns
2453+
/// the substring after the prefix and before the suffix, wrapped in `Some`.
2454+
/// Unlike [`trim_start_matches`] and [`trim_end_matches`], this method removes both the prefix
2455+
/// and suffix exactly once.
2456+
///
2457+
/// If the string does not start with `prefix` or does not end with `suffix`, returns `None`.
2458+
///
2459+
/// Each [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a
2460+
/// function or closure that determines if a character matches.
2461+
///
2462+
/// [`char`]: prim@char
2463+
/// [pattern]: self::pattern
2464+
/// [`trim_start_matches`]: Self::trim_start_matches
2465+
/// [`trim_end_matches`]: Self::trim_end_matches
2466+
///
2467+
/// # Examples
2468+
///
2469+
/// ```
2470+
/// #![feature(strip_circumfix)]
2471+
///
2472+
/// assert_eq!("bar:hello:foo".strip_circumfix("bar:", ":foo"), Some("hello"));
2473+
/// assert_eq!("bar:foo".strip_circumfix("foo", "foo"), None);
2474+
/// assert_eq!("foo:bar;".strip_circumfix("foo:", ';'), Some("bar"));
2475+
/// ```
2476+
#[must_use = "this returns the remaining substring as a new slice, \
2477+
without modifying the original"]
2478+
#[unstable(feature = "strip_circumfix", issue = "147946")]
2479+
pub fn strip_circumfix<P: Pattern, S: Pattern>(&self, prefix: P, suffix: S) -> Option<&str>
2480+
where
2481+
for<'a> S::Searcher<'a>: ReverseSearcher<'a>,
2482+
{
2483+
self.strip_prefix(prefix)?.strip_suffix(suffix)
2484+
}
2485+
24502486
/// Returns a string slice with the optional prefix removed.
24512487
///
24522488
/// If the string starts with the pattern `prefix`, returns the substring after the prefix.

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ target | std | host | notes
444444
`x86_64-uwp-windows-gnu` | ✓ | |
445445
[`x86_64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
446446
[`x86_64-win7-windows-gnu`](platform-support/win7-windows-gnu.md) | ✓ | | 64-bit Windows 7 support
447-
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support
447+
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support
448448
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
449449
[`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell)
450450
[`xtensa-esp32-espidf`](platform-support/esp-idf.md) | ✓ | | Xtensa ESP32

src/doc/rustc/src/platform-support/win7-windows-msvc.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Target triples:
1616

1717
This target supports all of core, alloc, std and test. This is automatically
1818
tested every night on private infrastructure hosted by the maintainer. Host
19-
tools may also work, though those are not currently tested.
19+
tools may also work, though it is not guaranteed. Last known success built
20+
version of rustc with host tools (x86_64) is 1.91.0.
2021

2122
Those targets follow Windows calling convention for extern "C".
2223

0 commit comments

Comments
 (0)