Skip to content

Commit 5ae4d75

Browse files
committed
Auto merge of #132099 - matthiaskrgr:rollup-myi94r8, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #129248 (Taking a raw ref (`&raw (const|mut)`) of a deref of pointer (`*ptr`) is always safe) - #131906 (rustdoc: adjust spacing and typography in header) - #132084 (Consider param-env candidates even if they have errors) - #132096 (Replace an FTP link in comments with an equivalent HTTPS link) - #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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 17 additions & 9 deletions
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

Lines changed: 3 additions & 11 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/crashes/115808.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)