Skip to content

Commit 5ae4d75

Browse files
committed
Auto merge of rust-lang#132099 - matthiaskrgr:rollup-myi94r8, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#129248 (Taking a raw ref (`&raw (const|mut)`) of a deref of pointer (`*ptr`) is always safe) - rust-lang#131906 (rustdoc: adjust spacing and typography in header) - rust-lang#132084 (Consider param-env candidates even if they have errors) - rust-lang#132096 (Replace an FTP link in comments with an equivalent HTTPS link) - rust-lang#132098 (rustc_feature::Features: explain what that 'Option<Symbol>' is about) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8aca4ba + 7c22f47 commit 5ae4d75

Some content is hidden

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

43 files changed

+156
-204
lines changed

compiler/rustc_data_structures/src/graph/dominators/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Algorithm based on Loukas Georgiadis,
44
//! "Linear-Time Algorithms for Dominators and Related Problems",
5-
//! <ftp://ftp.cs.princeton.edu/techreports/2005/737.pdf>
5+
//! <https://www.cs.princeton.edu/techreports/2005/737.pdf>
66
//!
77
//! Additionally useful is the original Lengauer-Tarjan paper on this subject,
88
//! "A Fast Algorithm for Finding Dominators in a Flowgraph"

compiler/rustc_feature/src/unstable.rs

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pub struct Features {
4444
}
4545

4646
impl Features {
47+
/// `since` should be set for stable features that are nevertheless enabled with a `#[feature]`
48+
/// attribute, indicating since when they are stable.
4749
pub fn set_enabled_lang_feature(&mut self, name: Symbol, span: Span, since: Option<Symbol>) {
4850
self.enabled_lang_features.push((name, span, since));
4951
self.enabled_features.insert(name);
@@ -54,6 +56,10 @@ impl Features {
5456
self.enabled_features.insert(name);
5557
}
5658

59+
/// Returns a list of triples with:
60+
/// - feature gate name
61+
/// - the span of the `#[feature]` attribute
62+
/// - (for already stable features) the version since which it is stable
5763
pub fn enabled_lang_features(&self) -> &Vec<(Symbol, Span, Option<Symbol>)> {
5864
&self.enabled_lang_features
5965
}

compiler/rustc_lint/src/builtin.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -2657,8 +2657,8 @@ declare_lint! {
26572657
///
26582658
/// ### Explanation
26592659
///
2660-
/// Dereferencing a null pointer causes [undefined behavior] even as a place expression,
2661-
/// like `&*(0 as *const i32)` or `addr_of!(*(0 as *const i32))`.
2660+
/// Dereferencing a null pointer causes [undefined behavior] if it is accessed
2661+
/// (loaded from or stored to).
26622662
///
26632663
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
26642664
pub DEREF_NULLPTR,
@@ -2673,14 +2673,14 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {
26732673
/// test if expression is a null ptr
26742674
fn is_null_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {
26752675
match &expr.kind {
2676-
rustc_hir::ExprKind::Cast(expr, ty) => {
2677-
if let rustc_hir::TyKind::Ptr(_) = ty.kind {
2676+
hir::ExprKind::Cast(expr, ty) => {
2677+
if let hir::TyKind::Ptr(_) = ty.kind {
26782678
return is_zero(expr) || is_null_ptr(cx, expr);
26792679
}
26802680
}
26812681
// check for call to `core::ptr::null` or `core::ptr::null_mut`
2682-
rustc_hir::ExprKind::Call(path, _) => {
2683-
if let rustc_hir::ExprKind::Path(ref qpath) = path.kind {
2682+
hir::ExprKind::Call(path, _) => {
2683+
if let hir::ExprKind::Path(ref qpath) = path.kind {
26842684
if let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id() {
26852685
return matches!(
26862686
cx.tcx.get_diagnostic_name(def_id),
@@ -2697,7 +2697,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {
26972697
/// test if expression is the literal `0`
26982698
fn is_zero(expr: &hir::Expr<'_>) -> bool {
26992699
match &expr.kind {
2700-
rustc_hir::ExprKind::Lit(lit) => {
2700+
hir::ExprKind::Lit(lit) => {
27012701
if let LitKind::Int(a, _) = lit.node {
27022702
return a == 0;
27032703
}
@@ -2707,8 +2707,16 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {
27072707
false
27082708
}
27092709

2710-
if let rustc_hir::ExprKind::Unary(rustc_hir::UnOp::Deref, expr_deref) = expr.kind {
2711-
if is_null_ptr(cx, expr_deref) {
2710+
if let hir::ExprKind::Unary(hir::UnOp::Deref, expr_deref) = expr.kind
2711+
&& is_null_ptr(cx, expr_deref)
2712+
{
2713+
if let hir::Node::Expr(hir::Expr {
2714+
kind: hir::ExprKind::AddrOf(hir::BorrowKind::Raw, ..),
2715+
..
2716+
}) = cx.tcx.parent_hir_node(expr.hir_id)
2717+
{
2718+
// `&raw *NULL` is ok.
2719+
} else {
27122720
cx.emit_span_lint(DEREF_NULLPTR, expr.span, BuiltinDerefNullptr {
27132721
label: expr.span,
27142722
});

compiler/rustc_mir_build/src/check_unsafety.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -509,20 +509,12 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
509509
}
510510
ExprKind::RawBorrow { arg, .. } => {
511511
if let ExprKind::Scope { value: arg, .. } = self.thir[arg].kind
512-
// THIR desugars UNSAFE_STATIC into *UNSAFE_STATIC_REF, where
513-
// UNSAFE_STATIC_REF holds the addr of the UNSAFE_STATIC, so: take two steps
514512
&& let ExprKind::Deref { arg } = self.thir[arg].kind
515-
// FIXME(workingjubiee): we lack a clear reason to reject ThreadLocalRef here,
516-
// but we also have no conclusive reason to allow it either!
517-
&& let ExprKind::StaticRef { .. } = self.thir[arg].kind
518513
{
519-
// A raw ref to a place expr, even an "unsafe static", is okay!
520-
// We short-circuit to not recursively traverse this expression.
514+
// Taking a raw ref to a deref place expr is always safe.
515+
// Make sure the expression we're deref'ing is safe, though.
516+
visit::walk_expr(self, &self.thir[arg]);
521517
return;
522-
// note: const_mut_refs enables this code, and it currently remains unsafe:
523-
// static mut BYTE: u8 = 0;
524-
// static mut BYTE_PTR: *mut u8 = unsafe { addr_of_mut!(BYTE) };
525-
// static mut DEREF_BYTE_PTR: *mut u8 = unsafe { addr_of_mut!(*BYTE_PTR) };
526518
}
527519
}
528520
ExprKind::Deref { arg } => {

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
244244
.param_env
245245
.caller_bounds()
246246
.iter()
247-
.filter(|p| !p.references_error())
248247
.filter_map(|p| p.as_trait_clause())
249248
// Micro-optimization: filter out predicates relating to different traits.
250249
.filter(|p| p.def_id() == stack.obligation.predicate.def_id())

src/librustdoc/html/render/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2010,9 +2010,9 @@ fn render_rightside(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, render
20102010
);
20112011
if let Some(link) = src_href {
20122012
if has_stability {
2013-
write!(rightside, " · <a class=\"src\" href=\"{link}\">source</a>")
2013+
write!(rightside, " · <a class=\"src\" href=\"{link}\">Source</a>")
20142014
} else {
2015-
write!(rightside, "<a class=\"src rightside\" href=\"{link}\">source</a>")
2015+
write!(rightside, "<a class=\"src rightside\" href=\"{link}\">Source</a>")
20162016
}
20172017
}
20182018
if has_stability && has_src_ref {

src/librustdoc/html/static/css/rustdoc.css

+8-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ h1, h2, h3, h4 {
185185
grid-template-columns: minmax(105px, 1fr) minmax(0, max-content);
186186
grid-template-rows: minmax(25px, min-content) min-content min-content;
187187
padding-bottom: 6px;
188-
margin-bottom: 11px;
188+
margin-bottom: 15px;
189189
}
190190
.rustdoc-breadcrumbs {
191191
grid-area: main-heading-breadcrumbs;
@@ -1004,6 +1004,7 @@ nav.sub {
10041004
display: flex;
10051005
height: 34px;
10061006
flex-grow: 1;
1007+
margin-bottom: 4px;
10071008
}
10081009
.src nav.sub {
10091010
margin: 0 0 -10px 0;
@@ -2253,7 +2254,12 @@ in src-script.js and main.js
22532254

22542255
/* We don't display this button on mobile devices. */
22552256
#copy-path {
2256-
display: none;
2257+
/* display: none; avoided as a layout hack.
2258+
When there's one line, we get an effective line-height of 34px,
2259+
because that's how big the image is, but if the header wraps,
2260+
they're packed more tightly than that. */
2261+
width: 0;
2262+
visibility: hidden;
22572263
}
22582264

22592265
/* Text label takes up too much space at this size. */

src/librustdoc/html/templates/print_item.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1>
2626
{% match src_href %}
2727
{% when Some with (href) %}
2828
{% if !stability_since_raw.is_empty() +%} · {%+ endif %}
29-
<a class="src" href="{{href|safe}}">source</a> {#+ #}
29+
<a class="src" href="{{href|safe}}">Source</a> {#+ #}
3030
{% else %}
3131
{% endmatch %}
3232
</span> {# #}

tests/crashes/110630.rs

-28
This file was deleted.

tests/crashes/115808.rs

-27
This file was deleted.

tests/crashes/121052.rs

-32
This file was deleted.

tests/rustdoc-gui/item-info.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ store-position: (
2020
{"x": second_line_x, "y": second_line_y},
2121
)
2222
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272
23-
assert: |first_line_y| != |second_line_y| && |first_line_y| == 714 && |second_line_y| == 737
23+
assert: |first_line_y| != |second_line_y| && |first_line_y| == 718 && |second_line_y| == 741
2424

2525
// Now we ensure that they're not rendered on the same line.
2626
set-window-size: (1100, 800)

tests/rustdoc-gui/scrape-examples-layout.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ click: ".scraped-example .button-holder .expand"
8080
store-value: (offset_y, 4)
8181

8282
// First with desktop
83-
assert-position: (".scraped-example", {"y": 252})
84-
assert-position: (".scraped-example .prev", {"y": 252 + |offset_y|})
83+
assert-position: (".scraped-example", {"y": 256})
84+
assert-position: (".scraped-example .prev", {"y": 256 + |offset_y|})
8585

8686
// Gradient background should be at the top of the code block.
8787
assert-css: (".scraped-example .example-wrap::before", {"top": "0px"})
@@ -90,8 +90,8 @@ assert-css: (".scraped-example .example-wrap::after", {"bottom": "0px"})
9090
// Then with mobile
9191
set-window-size: (600, 600)
9292
store-size: (".scraped-example .scraped-example-title", {"height": title_height})
93-
assert-position: (".scraped-example", {"y": 287})
94-
assert-position: (".scraped-example .prev", {"y": 287 + |offset_y| + |title_height|})
93+
assert-position: (".scraped-example", {"y": 291})
94+
assert-position: (".scraped-example .prev", {"y": 291 + |offset_y| + |title_height|})
9595

9696
define-function: (
9797
"check_title_and_code_position",

tests/rustdoc-gui/sidebar-source-code-display.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ click: "#sidebar-button"
141141
wait-for-css: (".src .sidebar > *", {"visibility": "hidden"})
142142
// We scroll to line 117 to change the scroll position.
143143
scroll-to: '//*[@id="117"]'
144-
store-value: (y_offset, "2570")
144+
store-value: (y_offset, "2578")
145145
assert-window-property: {"pageYOffset": |y_offset|}
146146
// Expanding the sidebar...
147147
click: "#sidebar-button"

tests/rustdoc-gui/source-anchor-scroll.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ set-window-size: (600, 800)
88
assert-property: ("html", {"scrollTop": "0"})
99

1010
click: '//a[text() = "barbar" and @href="#5-7"]'
11-
assert-property: ("html", {"scrollTop": "200"})
11+
assert-property: ("html", {"scrollTop": "208"})
1212
click: '//a[text() = "bar" and @href="#28-36"]'
13-
assert-property: ("html", {"scrollTop": "231"})
13+
assert-property: ("html", {"scrollTop": "239"})
1414
click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]'
15-
assert-property: ("html", {"scrollTop": "128"})
15+
assert-property: ("html", {"scrollTop": "136"})
1616

1717
// We now check that clicking on lines doesn't change the scroll
1818
// Extra information: the "sub_fn" function header is on line 1.
1919
click: '//*[@id="6"]'
20-
assert-property: ("html", {"scrollTop": "128"})
20+
assert-property: ("html", {"scrollTop": "136"})

tests/rustdoc-gui/source-code-page.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
8989
// do anything (and certainly not add a `#NaN` to the URL!).
9090
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
9191
// We use this assert-position to know where we will click.
92-
assert-position: ("//*[@id='1']", {"x": 88, "y": 163})
92+
assert-position: ("//*[@id='1']", {"x": 88, "y": 171})
9393
// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
9494
click: (163, 77)
9595
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
@@ -165,15 +165,15 @@ assert-css: ("nav.sub", {"flex-direction": "row"})
165165
// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form]
166166
assert-position: ("nav.sub form", {"y": 15})
167167
assert-property: ("nav.sub form", {"offsetHeight": 34})
168-
assert-position: ("h1", {"y": 64})
168+
assert-position: ("h1", {"y": 68})
169169
// 15 = 64 - 34 - 15
170170

171171
// Now do the same check on moderately-sized, tablet mobile.
172172
set-window-size: (700, 700)
173173
assert-css: ("nav.sub", {"flex-direction": "row"})
174174
assert-position: ("nav.sub form", {"y": 8})
175175
assert-property: ("nav.sub form", {"offsetHeight": 34})
176-
assert-position: ("h1", {"y": 50})
176+
assert-position: ("h1", {"y": 54})
177177
// 8 = 50 - 34 - 8
178178

179179
// Check the sidebar directory entries have a marker and spacing (tablet).
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="associatedconstant.YOLO" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
1+
<section id="associatedconstant.YOLO" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#16">Source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="associatedconstant.X" class="associatedconstant"><a class="src rightside" href="../src/foo/anchors.rs.html#42">source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section>
1+
<section id="associatedconstant.X" class="associatedconstant"><a class="src rightside" href="../src/foo/anchors.rs.html#42">Source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section>
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="method.new" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section>
1+
<section id="method.new" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#48">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="method.bar" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fn">bar</a>()</h4></section>
1+
<section id="method.bar" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#23">Source</a><h4 class="code-header">fn <a href="#method.bar" class="fn">bar</a>()</h4></section>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="tymethod.foo" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fn">foo</a>()</h4></section>
1+
<section id="tymethod.foo" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#20">Source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fn">foo</a>()</h4></section>
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="associatedtype.T" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></section>
1+
<section id="associatedtype.T" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#13">Source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></section>
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<section id="associatedtype.Y" class="associatedtype"><a class="src rightside" href="../src/foo/anchors.rs.html#45">source</a><h4 class="code-header">pub type <a href="#associatedtype.Y" class="associatedtype">Y</a> = <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
1+
<section id="associatedtype.Y" class="associatedtype"><a class="src rightside" href="../src/foo/anchors.rs.html#45">Source</a><h4 class="code-header">pub type <a href="#associatedtype.Y" class="associatedtype">Y</a> = <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>

tests/rustdoc/assoc-type-source-link.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pub struct Bar;
99

1010
impl Bar {
11-
//@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a' 'source'
11+
//@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a' 'Source'
1212
//@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a/@href' \
1313
// '../src/foo/assoc-type-source-link.rs.html#14'
1414
pub type Y = u8;
@@ -19,7 +19,7 @@ pub trait Foo {
1919
}
2020

2121
impl Foo for Bar {
22-
//@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a' 'source'
22+
//@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a' 'Source'
2323
//@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a/@href' \
2424
// '../src/foo/assoc-type-source-link.rs.html#25'
2525
type Z = u8;

0 commit comments

Comments
 (0)