Skip to content

Commit cef44f5

Browse files
committed
Auto merge of rust-lang#105166 - matthiaskrgr:rollup-s9l6vt2, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#104614 (Add `type_ascribe!` macro as placeholder syntax for type ascription) - rust-lang#105126 (Make `VecDeque::new_in` unstably const) - rust-lang#105132 (Migrate summary toggle filter to CSS variable) - rust-lang#105136 (clarify comment on Deref promotion) - rust-lang#105137 (Add tracking issue number for `file_create_new` feature) - rust-lang#105143 (rustdoc: use simpler CSS for setting the font on scraped examples) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 11663b1 + 8e059d5 commit cef44f5

Some content is hidden

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

49 files changed

+337
-243
lines changed

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mod log_syntax;
4545
mod source_util;
4646
mod test;
4747
mod trace_macros;
48+
mod type_ascribe;
4849
mod util;
4950

5051
pub mod asm;
@@ -92,6 +93,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
9293
unreachable: edition_panic::expand_unreachable,
9394
stringify: source_util::expand_stringify,
9495
trace_macros: trace_macros::expand_trace_macros,
96+
type_ascribe: type_ascribe::expand_type_ascribe,
9597
}
9698

9799
register_attr! {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use rustc_ast::ptr::P;
2+
use rustc_ast::tokenstream::TokenStream;
3+
use rustc_ast::{token, Expr, ExprKind, Ty};
4+
use rustc_errors::PResult;
5+
use rustc_expand::base::{self, DummyResult, ExtCtxt, MacEager};
6+
use rustc_span::Span;
7+
8+
pub fn expand_type_ascribe(
9+
cx: &mut ExtCtxt<'_>,
10+
span: Span,
11+
tts: TokenStream,
12+
) -> Box<dyn base::MacResult + 'static> {
13+
let (expr, ty) = match parse_ascribe(cx, tts) {
14+
Ok(parsed) => parsed,
15+
Err(mut err) => {
16+
err.emit();
17+
return DummyResult::any(span);
18+
}
19+
};
20+
21+
let asc_expr = cx.expr(span, ExprKind::Type(expr, ty));
22+
23+
return MacEager::expr(asc_expr);
24+
}
25+
26+
fn parse_ascribe<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P<Expr>, P<Ty>)> {
27+
let mut parser = cx.new_parser_from_tts(stream);
28+
29+
let expr = parser.parse_expr()?;
30+
parser.expect(&token::Comma)?;
31+
32+
let ty = parser.parse_ty()?;
33+
34+
Ok((expr, ty))
35+
}

compiler/rustc_const_eval/src/transform/promote_consts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,14 @@ impl<'tcx> Validator<'_, 'tcx> {
318318
match elem {
319319
ProjectionElem::Deref => {
320320
let mut promotable = false;
321+
// When a static is used by-value, that gets desugared to `*STATIC_ADDR`,
322+
// and we need to be able to promote this. So check if this deref matches
323+
// that specific pattern.
324+
321325
// We need to make sure this is a `Deref` of a local with no further projections.
322326
// Discussion can be found at
323327
// https://github.com/rust-lang/rust/pull/74945#discussion_r463063247
324328
if let Some(local) = place_base.as_local() {
325-
// This is a special treatment for cases like *&STATIC where STATIC is a
326-
// global static variable.
327-
// This pattern is generated only when global static variables are directly
328-
// accessed and is qualified for promotion safely.
329329
if let TempState::Defined { location, .. } = self.temps[local] {
330330
let def_stmt = self.body[location.block]
331331
.statements

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,7 @@ symbols! {
14881488
ty,
14891489
type_alias_enum_variants,
14901490
type_alias_impl_trait,
1491+
type_ascribe,
14911492
type_ascription,
14921493
type_changing_struct_update,
14931494
type_id,

library/alloc/src/collections/vec_deque/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,9 @@ impl<T, A: Allocator> VecDeque<T, A> {
566566
///
567567
/// let deque: VecDeque<u32> = VecDeque::new();
568568
/// ```
569-
// FIXME: This should probably be const
570569
#[inline]
571570
#[unstable(feature = "allocator_api", issue = "32838")]
572-
pub fn new_in(alloc: A) -> VecDeque<T, A> {
571+
pub const fn new_in(alloc: A) -> VecDeque<T, A> {
573572
VecDeque { head: 0, len: 0, buf: RawVec::new_in(alloc) }
574573
}
575574

@@ -2152,7 +2151,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
21522151

21532152
self.head = tail;
21542153
} else {
2155-
// ´free` is smaller than both `head_len` and `tail_len`.
2154+
// `free` is smaller than both `head_len` and `tail_len`.
21562155
// the general algorithm for this first moves the slices
21572156
// right next to each other and then uses `slice::rotate`
21582157
// to rotate them into place:

library/core/src/macros/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,18 @@ pub(crate) mod builtin {
15461546
/* compiler built-in */
15471547
}
15481548

1549+
/// Unstable placeholder for type ascription.
1550+
#[rustc_builtin_macro]
1551+
#[unstable(
1552+
feature = "type_ascription",
1553+
issue = "23416",
1554+
reason = "placeholder syntax for type ascription"
1555+
)]
1556+
#[cfg(not(bootstrap))]
1557+
pub macro type_ascribe($expr:expr, $ty:ty) {
1558+
/* compiler built-in */
1559+
}
1560+
15491561
/// Unstable implementation detail of the `rustc` compiler, do not use.
15501562
#[rustc_builtin_macro]
15511563
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/prelude/v1.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,11 @@ pub use crate::macros::builtin::cfg_accessible;
9898
reason = "`cfg_eval` is a recently implemented feature"
9999
)]
100100
pub use crate::macros::builtin::cfg_eval;
101+
102+
#[unstable(
103+
feature = "type_ascription",
104+
issue = "23416",
105+
reason = "placeholder syntax for type ascription"
106+
)]
107+
#[cfg(not(bootstrap))]
108+
pub use crate::macros::builtin::type_ascribe;

library/std/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl File {
401401
/// Ok(())
402402
/// }
403403
/// ```
404-
#[unstable(feature = "file_create_new", issue = "none")]
404+
#[unstable(feature = "file_create_new", issue = "105135")]
405405
pub fn create_new<P: AsRef<Path>>(path: P) -> io::Result<File> {
406406
OpenOptions::new().read(true).write(true).create_new(true).open(path.as_ref())
407407
}

library/std/src/prelude/v1.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ pub use core::prelude::v1::cfg_accessible;
8585
)]
8686
pub use core::prelude::v1::cfg_eval;
8787

88+
// Do not `doc(no_inline)` either.
89+
#[unstable(
90+
feature = "type_ascription",
91+
issue = "23416",
92+
reason = "placeholder syntax for type ascription"
93+
)]
94+
#[cfg(not(bootstrap))]
95+
pub use core::prelude::v1::type_ascribe;
96+
8897
// The file so far is equivalent to src/libcore/prelude/v1.rs,
8998
// and below to src/liballoc/prelude.rs.
9099
// Those files are duplicated rather than using glob imports

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,7 @@ a.srclink,
197197
#help-button > a,
198198
details.rustdoc-toggle.top-doc > summary,
199199
details.rustdoc-toggle.non-exhaustive > summary,
200-
.scraped-example-title,
201-
.more-examples-toggle summary, .more-examples-toggle .hide-more,
202-
.example-links a,
200+
.scraped-example-list,
203201
/* This selector is for the items listed in the "all items" page. */
204202
ul.all-items {
205203
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
@@ -1516,6 +1514,7 @@ details.rustdoc-toggle > summary::before {
15161514
display: inline-block;
15171515
vertical-align: middle;
15181516
opacity: .5;
1517+
filter: var(--toggle-filter);
15191518
}
15201519

15211520
details.rustdoc-toggle > summary.hideme > span,

0 commit comments

Comments
 (0)