Skip to content

Commit

Permalink
Auto merge of rust-lang#125257 - jieyouxu:rollup-11evnm9, r=jieyouxu
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed May 18, 2024
2 parents eb1a5c9 + c367d99 commit b1ec1bd
Show file tree
Hide file tree
Showing 13 changed files with 1,844 additions and 57 deletions.
12 changes: 11 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,9 +1778,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// If this type is a GAT, and of the GAT args resolve to something new,
// that means that we must have newly inferred something about the GAT.
// We should give up in that case.
// FIXME(generic-associated-types): This only detects one layer of inference,
// which is probably not what we actually want, but fixing it causes some ambiguity:
// <https://github.com/rust-lang/rust/issues/125196>.
if !generics.own_params.is_empty()
&& obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
p.has_non_region_infer() && self.infcx.resolve_vars_if_possible(p) != p
p.has_non_region_infer()
&& match p.unpack() {
ty::GenericArgKind::Const(ct) => {
self.infcx.shallow_resolve_const(ct) != ct
}
ty::GenericArgKind::Type(ty) => self.infcx.shallow_resolve(ty) != ty,
ty::GenericArgKind::Lifetime(_) => false,
}
})
{
ProjectionMatchesProjection::Ambiguous
Expand Down
12 changes: 7 additions & 5 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1940,8 +1940,10 @@ impl String {

/// Converts this `String` into a <code>[Box]<[str]></code>.
///
/// This will drop any excess capacity.
/// Before doing the conversion, this method discards excess capacity like [`shrink_to_fit`].
/// Note that this call may reallocate and copy the bytes of the string.
///
/// [`shrink_to_fit`]: String::shrink_to_fit
/// [str]: prim@str "str"
///
/// # Examples
Expand All @@ -1967,10 +1969,10 @@ impl String {
/// this function is ideally used for data that lives for the remainder of the program's life,
/// as dropping the returned reference will cause a memory leak.
///
/// It does not reallocate or shrink the `String`,
/// so the leaked allocation may include unused capacity that is not part
/// of the returned slice. If you don't want that, call [`into_boxed_str`],
/// and then [`Box::leak`].
/// It does not reallocate or shrink the `String`, so the leaked allocation may include unused
/// capacity that is not part of the returned slice. If you want to discard excess capacity,
/// call [`into_boxed_str`], and then [`Box::leak`] instead. However, keep in mind that
/// trimming the capacity may result in a reallocation and copy.
///
/// [`into_boxed_str`]: Self::into_boxed_str
///
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,6 @@ ui/macros/issue-95267.rs
ui/macros/issue-95533.rs
ui/macros/issue-98466-allow.rs
ui/macros/issue-98466.rs
ui/macros/issue-98790.rs
ui/macros/issue-99261.rs
ui/macros/issue-99265.rs
ui/macros/issue-99907.rs
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
"tests/ui/macros/not-utf8.bin", // testing including data with the include macros
"tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include
"tests/ui/proc-macro/auxiliary/included-file.txt", // more include
"tests/ui/unpretty/auxiliary/data.txt", // more include
"tests/ui/invalid/foo.natvis.xml", // sample debugger visualizer
"tests/ui/sanitizer/dataflow-abilist.txt", // dataflow sanitizer ABI list file
"tests/ui/shell-argfiles/shell-argfiles.args", // passing args via a file
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Fix for <https://github.com/rust-lang/rust/issues/125196>.
//@ check-pass

trait Tr {
type Gat<T>;
}

struct W<T>(T);

fn foo<T: Tr>() where for<'a> &'a T: Tr<Gat<W<i32>> = i32> {
let x: <&T as Tr>::Gat<W<_>> = 1i32;
// Previously, `match_projection_projections` only checked that
// `shallow_resolve(W<?0>) = W<?0>`. This won't prevent *all* inference guidance
// from projection predicates in the environment, just ones that guide the
// outermost type of each GAT constructor. This is definitely wrong, but there is
// code that relies on it in the wild :/
}

fn main() {}
24 changes: 0 additions & 24 deletions tests/ui/macros/issue-98790.rs

This file was deleted.

1 change: 1 addition & 0 deletions tests/ui/unpretty/auxiliary/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data for include_bytes in ../expanded-exhaustive.rs
Loading

0 comments on commit b1ec1bd

Please sign in to comment.