Skip to content

Commit c67cb3e

Browse files
committed
Auto merge of #113878 - matthiaskrgr:rollup-u0d3kzx, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #113710 (Fix rpath for libdir is specified) - #113787 (Update documentation for std::process::Command's new method) - #113795 (Properly document `lifetime_mapping` in `OpaqueTy`) - #113857 (Add tests for `--document-hidden-items` option) - #113871 (Use the correct span for displaying the line following a derive sugge…) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0646a5d + 770c8d0 commit c67cb3e

File tree

9 files changed

+114
-19
lines changed

9 files changed

+114
-19
lines changed

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -1619,13 +1619,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16191619
debug!(?hir_bounds);
16201620

16211621
let lifetime_mapping = if in_trait {
1622-
self.arena.alloc_from_iter(
1623-
collected_lifetime_mapping
1624-
.iter()
1625-
.map(|(lifetime, def_id)| (**lifetime, *def_id)),
1622+
Some(
1623+
&*self.arena.alloc_from_iter(
1624+
collected_lifetime_mapping
1625+
.iter()
1626+
.map(|(lifetime, def_id)| (**lifetime, *def_id)),
1627+
),
16261628
)
16271629
} else {
1628-
&mut []
1630+
None
16291631
};
16301632

16311633
let opaque_ty_item = hir::OpaqueTy {
@@ -2090,13 +2092,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20902092
debug!("lower_async_fn_ret_ty: generic_params={:#?}", generic_params);
20912093

20922094
let lifetime_mapping = if in_trait {
2093-
self.arena.alloc_from_iter(
2094-
collected_lifetime_mapping
2095-
.iter()
2096-
.map(|(lifetime, def_id)| (**lifetime, *def_id)),
2095+
Some(
2096+
&*self.arena.alloc_from_iter(
2097+
collected_lifetime_mapping
2098+
.iter()
2099+
.map(|(lifetime, def_id)| (**lifetime, *def_id)),
2100+
),
20972101
)
20982102
} else {
2099-
&mut []
2103+
None
21002104
};
21012105

21022106
let opaque_ty_item = hir::OpaqueTy {

Diff for: compiler/rustc_errors/src/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ impl EmitterWriter {
19821982
// We special case `#[derive(_)]\n` and other attribute suggestions, because those
19831983
// are the ones where context is most useful.
19841984
let file_lines = sm
1985-
.span_to_lines(span.primary_span().unwrap().shrink_to_hi())
1985+
.span_to_lines(parts[0].span.shrink_to_hi())
19861986
.expect("span_to_lines failed when emitting suggestion");
19871987
let line_num = sm.lookup_char_pos(parts[0].span.lo()).line;
19881988
if let Some(line) = file_lines.file.get_line(line_num - 1) {

Diff for: compiler/rustc_hir/src/hir.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -2664,10 +2664,19 @@ pub struct OpaqueTy<'hir> {
26642664
pub generics: &'hir Generics<'hir>,
26652665
pub bounds: GenericBounds<'hir>,
26662666
pub origin: OpaqueTyOrigin,
2667-
// Opaques have duplicated lifetimes, this mapping connects the original lifetime with the copy
2668-
// so we can later generate bidirectional outlives predicates to enforce that these lifetimes
2669-
// stay in sync.
2670-
pub lifetime_mapping: &'hir [(Lifetime, LocalDefId)],
2667+
/// Return-position impl traits (and async futures) must "reify" any late-bound
2668+
/// lifetimes that are captured from the function signature they originate from.
2669+
///
2670+
/// This is done by generating a new early-bound lifetime parameter local to the
2671+
/// opaque which is substituted in the function signature with the late-bound
2672+
/// lifetime.
2673+
///
2674+
/// This mapping associated a captured lifetime (first parameter) with the new
2675+
/// early-bound lifetime that was generated for the opaque.
2676+
pub lifetime_mapping: Option<&'hir [(Lifetime, LocalDefId)]>,
2677+
/// Whether the opaque is a return-position impl trait (or async future)
2678+
/// originating from a trait method. This makes it so that the opaque is
2679+
/// lowered as an associated type.
26712680
pub in_trait: bool,
26722681
}
26732682

Diff for: compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
6666
let opaque_ty_id = tcx.hir().local_def_id_to_hir_id(opaque_def_id.expect_local());
6767
let opaque_ty_node = tcx.hir().get(opaque_ty_id);
6868
let Node::Item(&Item {
69-
kind: ItemKind::OpaqueTy(OpaqueTy { lifetime_mapping, .. }),
69+
kind: ItemKind::OpaqueTy(OpaqueTy { lifetime_mapping: Some(lifetime_mapping), .. }),
7070
..
7171
}) = opaque_ty_node
7272
else {

Diff for: library/std/src/process.rs

+8
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,14 @@ impl Command {
558558
/// but this has some implementation limitations on Windows
559559
/// (see issue #37519).
560560
///
561+
/// # Platform-specific behavior
562+
///
563+
/// Note on Windows: For executable files with the .exe extension,
564+
/// it can be omitted when specifying the program for this Command.
565+
/// However, if the file has a different extension,
566+
/// a filename including the extension needs to be provided,
567+
/// otherwise the file won't be found.
568+
///
561569
/// # Examples
562570
///
563571
/// Basic usage:

Diff for: src/bootstrap/builder.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1629,17 +1629,18 @@ impl<'a> Builder<'a> {
16291629
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
16301630
// to change a flag in a binary?
16311631
if self.config.rpath_enabled(target) && util::use_host_linker(target) {
1632+
let libdir = self.sysroot_libdir_relative(compiler).to_str().unwrap();
16321633
let rpath = if target.contains("apple") {
16331634
// Note that we need to take one extra step on macOS to also pass
16341635
// `-Wl,-instal_name,@rpath/...` to get things to work right. To
16351636
// do that we pass a weird flag to the compiler to get it to do
16361637
// so. Note that this is definitely a hack, and we should likely
16371638
// flesh out rpath support more fully in the future.
16381639
rustflags.arg("-Zosx-rpath-install-name");
1639-
Some("-Wl,-rpath,@loader_path/../lib")
1640+
Some(format!("-Wl,-rpath,@loader_path/../{}", libdir))
16401641
} else if !target.contains("windows") && !target.contains("aix") {
16411642
rustflags.arg("-Clink-args=-Wl,-z,origin");
1642-
Some("-Wl,-rpath,$ORIGIN/../lib")
1643+
Some(format!("-Wl,-rpath,$ORIGIN/../{}", libdir))
16431644
} else {
16441645
None
16451646
};

Diff for: src/etc/htmldocck.py

+2
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ def get_commands(template):
274274
args = shlex.split(args)
275275
except UnicodeEncodeError:
276276
args = [arg.decode('utf-8') for arg in shlex.split(args.encode('utf-8'))]
277+
except Exception as exc:
278+
raise Exception("line {}: {}".format(lineno + 1, exc)) from None
277279
yield Command(negated=negated, cmd=cmd, args=args, lineno=lineno+1, context=line)
278280

279281

Diff for: tests/rustdoc/display-hidden-items.rs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Test to ensure that the `--document-hidden-items` option is working as expected.
2+
// compile-flags: -Z unstable-options --document-hidden-items
3+
// ignore-tidy-linelength
4+
5+
#![crate_name = "foo"]
6+
7+
// @has 'foo/index.html'
8+
// @has - '//*[@id="reexport.hidden_reexport"]/code' 'pub use hidden::inside_hidden as hidden_reexport;'
9+
#[doc(hidden)]
10+
pub use hidden::inside_hidden as hidden_reexport;
11+
12+
// @has - '//*[@class="item-name"]/a[@class="trait"]' 'TraitHidden'
13+
// @has 'foo/trait.TraitHidden.html'
14+
#[doc(hidden)]
15+
pub trait TraitHidden {}
16+
17+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="trait"]' 'Trait'
18+
pub trait Trait {
19+
// @has 'foo/trait.Trait.html'
20+
// @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' 'const BAR: u32 = 0u32'
21+
#[doc(hidden)]
22+
const BAR: u32 = 0;
23+
24+
// @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()'
25+
#[doc(hidden)]
26+
fn foo() {}
27+
}
28+
29+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="struct"]' 'Struct'
30+
// @has 'foo/struct.Struct.html'
31+
pub struct Struct {
32+
// @has - '//*[@id="structfield.a"]/code' 'a: u32'
33+
#[doc(hidden)]
34+
pub a: u32,
35+
}
36+
37+
impl Struct {
38+
// @has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> Self'
39+
#[doc(hidden)]
40+
pub fn new() -> Self { Self { a: 0 } }
41+
}
42+
43+
impl Trait for Struct {
44+
// @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' 'const BAR: u32 = 0u32'
45+
// @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()'
46+
}
47+
// @has - '//*[@id="impl-TraitHidden-for-Struct"]/*[@class="code-header"]' 'impl TraitHidden for Struct'
48+
impl TraitHidden for Struct {}
49+
50+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'HiddenEnum'
51+
// @has 'foo/enum.HiddenEnum.html'
52+
#[doc(hidden)]
53+
pub enum HiddenEnum {
54+
A,
55+
}
56+
57+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'Enum'
58+
pub enum Enum {
59+
// @has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]' 'A'
60+
#[doc(hidden)]
61+
A,
62+
}
63+
64+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="mod"]' 'hidden'
65+
#[doc(hidden)]
66+
pub mod hidden {
67+
// @has 'foo/hidden/index.html'
68+
// @has - '//*[@class="item-name"]/a[@class="fn"]' 'inside_hidden'
69+
// @has 'foo/hidden/fn.inside_hidden.html'
70+
pub fn inside_hidden() {}
71+
}

Diff for: tests/ui/modules/issue-107649.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ help: consider annotating `Dummy` with `#[derive(Debug)]`
1111
--> $DIR/auxiliary/dummy_lib.rs:2:1
1212
|
1313
2 + #[derive(Debug)]
14-
3 | #[path = "auxiliary/dummy_lib.rs"]
14+
3 | pub struct Dummy;
1515
|
1616

1717
error: aborting due to previous error

0 commit comments

Comments
 (0)