Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b1ec1bd

Browse files
committedMay 18, 2024
Auto merge of rust-lang#125257 - jieyouxu:rollup-11evnm9, r=jieyouxu
Rollup of 3 pull requests Successful merges: - rust-lang#125214 (Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability) - rust-lang#125236 (Add tests for `-Zunpretty=expanded` ported from stringify's tests) - rust-lang#125251 (Clarify how String::leak and into_boxed_str differ ) r? `@ghost` `@rustbot` modify labels: rollup
2 parents eb1a5c9 + c367d99 commit b1ec1bd

File tree

13 files changed

+1844
-57
lines changed

13 files changed

+1844
-57
lines changed
 

‎compiler/rustc_trait_selection/src/traits/select/mod.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1778,9 +1778,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17781778
// If this type is a GAT, and of the GAT args resolve to something new,
17791779
// that means that we must have newly inferred something about the GAT.
17801780
// We should give up in that case.
1781+
// FIXME(generic-associated-types): This only detects one layer of inference,
1782+
// which is probably not what we actually want, but fixing it causes some ambiguity:
1783+
// <https://github.com/rust-lang/rust/issues/125196>.
17811784
if !generics.own_params.is_empty()
17821785
&& obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
1783-
p.has_non_region_infer() && self.infcx.resolve_vars_if_possible(p) != p
1786+
p.has_non_region_infer()
1787+
&& match p.unpack() {
1788+
ty::GenericArgKind::Const(ct) => {
1789+
self.infcx.shallow_resolve_const(ct) != ct
1790+
}
1791+
ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
1792+
ty::GenericArgKind::Lifetime(_) => false,
1793+
}
17841794
})
17851795
{
17861796
ProjectionMatchesProjection::Ambiguous

‎library/alloc/src/string.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1940,8 +1940,10 @@ impl String {
19401940

19411941
/// Converts this `String` into a <code>[Box]<[str]></code>.
19421942
///
1943-
/// This will drop any excess capacity.
1943+
/// Before doing the conversion, this method discards excess capacity like [`shrink_to_fit`].
1944+
/// Note that this call may reallocate and copy the bytes of the string.
19441945
///
1946+
/// [`shrink_to_fit`]: String::shrink_to_fit
19451947
/// [str]: prim@str "str"
19461948
///
19471949
/// # Examples
@@ -1967,10 +1969,10 @@ impl String {
19671969
/// this function is ideally used for data that lives for the remainder of the program's life,
19681970
/// as dropping the returned reference will cause a memory leak.
19691971
///
1970-
/// It does not reallocate or shrink the `String`,
1971-
/// so the leaked allocation may include unused capacity that is not part
1972-
/// of the returned slice. If you don't want that, call [`into_boxed_str`],
1973-
/// and then [`Box::leak`].
1972+
/// It does not reallocate or shrink the `String`, so the leaked allocation may include unused
1973+
/// capacity that is not part of the returned slice. If you want to discard excess capacity,
1974+
/// call [`into_boxed_str`], and then [`Box::leak`] instead. However, keep in mind that
1975+
/// trimming the capacity may result in a reallocation and copy.
19741976
///
19751977
/// [`into_boxed_str`]: Self::into_boxed_str
19761978
///

‎src/tools/tidy/src/issues.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,6 @@ ui/macros/issue-95267.rs
29152915
ui/macros/issue-95533.rs
29162916
ui/macros/issue-98466-allow.rs
29172917
ui/macros/issue-98466.rs
2918-
ui/macros/issue-98790.rs
29192918
ui/macros/issue-99261.rs
29202919
ui/macros/issue-99265.rs
29212920
ui/macros/issue-99907.rs

‎src/tools/tidy/src/ui_tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
4141
"tests/ui/macros/not-utf8.bin", // testing including data with the include macros
4242
"tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include
4343
"tests/ui/proc-macro/auxiliary/included-file.txt", // more include
44+
"tests/ui/unpretty/auxiliary/data.txt", // more include
4445
"tests/ui/invalid/foo.natvis.xml", // sample debugger visualizer
4546
"tests/ui/sanitizer/dataflow-abilist.txt", // dataflow sanitizer ABI list file
4647
"tests/ui/shell-argfiles/shell-argfiles.args", // passing args via a file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Fix for <https://github.com/rust-lang/rust/issues/125196>.
2+
//@ check-pass
3+
4+
trait Tr {
5+
type Gat<T>;
6+
}
7+
8+
struct W<T>(T);
9+
10+
fn foo<T: Tr>() where for<'a> &'a T: Tr<Gat<W<i32>> = i32> {
11+
let x: <&T as Tr>::Gat<W<_>> = 1i32;
12+
// Previously, `match_projection_projections` only checked that
13+
// `shallow_resolve(W<?0>) = W<?0>`. This won't prevent *all* inference guidance
14+
// from projection predicates in the environment, just ones that guide the
15+
// outermost type of each GAT constructor. This is definitely wrong, but there is
16+
// code that relies on it in the wild :/
17+
}
18+
19+
fn main() {}

‎tests/ui/macros/issue-98790.rs

-24
This file was deleted.

‎tests/ui/unpretty/auxiliary/data.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data for include_bytes in ../expanded-exhaustive.rs
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.