Skip to content

Commit e48ace9

Browse files
committed
Auto merge of #150537 - Zalathar:rollup-ddm3q0n, r=Zalathar
Rollup of 4 pull requests Successful merges: - #143741 (`oneshot` Channel) - #146798 (RISC-V: Implement (Zkne or Zknd) intrinsics correctly) - #150337 (docs: fix typo in std::io::buffered) - #150530 (Remove `feature(string_deref_patterns)`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2848c2e + a1c5501 commit e48ace9

29 files changed

Lines changed: 883 additions & 173 deletions

File tree

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
262262
"power8-crypto" => Some(LLVMFeature::new("crypto")),
263263
s => Some(LLVMFeature::new(s)),
264264
},
265+
Arch::RiscV32 | Arch::RiscV64 => match s {
266+
// Filter out Rust-specific *virtual* target feature
267+
"zkne_or_zknd" => None,
268+
s => Some(LLVMFeature::new(s)),
269+
},
265270
Arch::Sparc | Arch::Sparc64 => match s {
266271
"leoncasa" => Some(LLVMFeature::new("hasleoncasa")),
267272
s => Some(LLVMFeature::new(s)),

compiler/rustc_feature/src/removed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ declare_features! (
271271
/// Allows `#[link(kind = "static-nobundle", ...)]`.
272272
(removed, static_nobundle, "1.63.0", Some(37403),
273273
Some(r#"subsumed by `#[link(kind = "static", modifiers = "-bundle", ...)]`"#), 95818),
274+
/// Allows string patterns to dereference values to match them.
275+
(removed, string_deref_patterns, "CURRENT_RUSTC_VERSION", Some(87121), Some("superseded by `deref_patterns`"), 150530),
274276
(removed, struct_inherit, "1.0.0", None, None),
275277
(removed, test_removed_feature, "1.0.0", None, None),
276278
/// Allows using items which are missing stability attributes

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,6 @@ declare_features! (
647647
(unstable, stmt_expr_attributes, "1.6.0", Some(15701)),
648648
/// Allows lints part of the strict provenance effort.
649649
(unstable, strict_provenance_lints, "1.61.0", Some(130351)),
650-
/// Allows string patterns to dereference values to match them.
651-
(unstable, string_deref_patterns, "1.67.0", Some(87121)),
652650
/// Allows `super let` statements.
653651
(unstable, super_let, "1.88.0", Some(139076)),
654652
/// Allows subtrait items to shadow supertrait items.

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -996,20 +996,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
996996
pat_ty = self.tcx.types.str_;
997997
}
998998

999-
if self.tcx.features().string_deref_patterns()
1000-
&& let hir::PatExprKind::Lit {
1001-
lit: Spanned { node: ast::LitKind::Str(..), .. }, ..
1002-
} = lt.kind
1003-
{
1004-
let tcx = self.tcx;
1005-
let expected = self.resolve_vars_if_possible(expected);
1006-
pat_ty = match expected.kind() {
1007-
ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::String) => expected,
1008-
ty::Str => Ty::new_static_str(tcx),
1009-
_ => pat_ty,
1010-
};
1011-
}
1012-
1013999
// Somewhat surprising: in this case, the subtyping relation goes the
10141000
// opposite way as the other cases. Actually what we really want is not
10151001
// a subtyping relation at all but rather that there exists a LUB

compiler/rustc_middle/src/thir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,6 @@ pub enum PatKind<'tcx> {
827827
/// much simpler.
828828
/// * raw pointers derived from integers, other raw pointers will have already resulted in an
829829
/// error.
830-
/// * `String`, if `string_deref_patterns` is enabled.
831830
Constant {
832831
value: ty::Value<'tcx>,
833832
},

compiler/rustc_mir_build/src/builder/matches/test.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
150150
let mut expect = self.literal_operand(test.span, Const::from_ty_value(tcx, value));
151151

152152
let mut place = place;
153-
let mut block = block;
153+
154154
match cast_ty.kind() {
155155
ty::Str => {
156156
// String literal patterns may have type `str` if `deref_patterns` is
@@ -175,34 +175,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
175175
place = ref_place;
176176
cast_ty = ref_str_ty;
177177
}
178-
ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::String) => {
179-
if !tcx.features().string_deref_patterns() {
180-
span_bug!(
181-
test.span,
182-
"matching on `String` went through without enabling string_deref_patterns"
183-
);
184-
}
185-
let re_erased = tcx.lifetimes.re_erased;
186-
let ref_str_ty = Ty::new_imm_ref(tcx, re_erased, tcx.types.str_);
187-
let ref_str = self.temp(ref_str_ty, test.span);
188-
let eq_block = self.cfg.start_new_block();
189-
// `let ref_str: &str = <String as Deref>::deref(&place);`
190-
self.call_deref(
191-
block,
192-
eq_block,
193-
place,
194-
Mutability::Not,
195-
cast_ty,
196-
ref_str,
197-
test.span,
198-
);
199-
// Since we generated a `ref_str = <String as Deref>::deref(&place) -> eq_block` terminator,
200-
// we need to add all further statements to `eq_block`.
201-
// Similarly, the normal test code should be generated for the `&str`, instead of the `String`.
202-
block = eq_block;
203-
place = ref_str;
204-
cast_ty = ref_str_ty;
205-
}
206178
&ty::Pat(base, _) => {
207179
assert_eq!(cast_ty, value.ty);
208180
assert!(base.is_trivially_pure_clone_copy());

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_abi::{FieldIdx, Integer};
1111
use rustc_errors::codes::*;
1212
use rustc_hir::def::{CtorOf, DefKind, Res};
1313
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
14-
use rustc_hir::{self as hir, LangItem, RangeEnd};
14+
use rustc_hir::{self as hir, RangeEnd};
1515
use rustc_index::Idx;
1616
use rustc_middle::mir::interpret::LitToConstInput;
1717
use rustc_middle::thir::{
@@ -626,23 +626,7 @@ impl<'tcx> PatCtxt<'tcx> {
626626
// the pattern's type will be `&[u8]` whereas the literal's type is `&[u8; 3]`; using the
627627
// pattern's type means we'll properly translate it to a slice reference pattern. This works
628628
// because slices and arrays have the same valtree representation.
629-
// HACK: As an exception, use the literal's type if `pat_ty` is `String`; this can happen if
630-
// `string_deref_patterns` is enabled. There's a special case for that when lowering to MIR.
631-
// FIXME(deref_patterns): This hack won't be necessary once `string_deref_patterns` is
632-
// superseded by a more general implementation of deref patterns.
633629
let ct_ty = match pat_ty {
634-
Some(pat_ty)
635-
if let ty::Adt(def, _) = *pat_ty.kind()
636-
&& self.tcx.is_lang_item(def.did(), LangItem::String) =>
637-
{
638-
if !self.tcx.features().string_deref_patterns() {
639-
span_bug!(
640-
expr.span,
641-
"matching on `String` went through without enabling string_deref_patterns"
642-
);
643-
}
644-
self.typeck_results.node_type(expr.hir_id)
645-
}
646630
Some(pat_ty) => pat_ty,
647631
None => self.typeck_results.node_type(expr.hir_id),
648632
};

compiler/rustc_target/src/target_features.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,9 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
690690
("zimop", Unstable(sym::riscv_target_feature), &[]),
691691
("zk", Stable, &["zkn", "zkr", "zkt"]),
692692
("zkn", Stable, &["zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"]),
693-
("zknd", Stable, &[]),
694-
("zkne", Stable, &[]),
693+
("zknd", Stable, &["zkne_or_zknd"]),
694+
("zkne", Stable, &["zkne_or_zknd"]),
695+
("zkne_or_zknd", Unstable(sym::riscv_target_feature), &[]), // Not an extension
695696
("zknh", Stable, &[]),
696697
("zkr", Stable, &[]),
697698
("zks", Stable, &["zbkb", "zbkc", "zbkx", "zksed", "zksh"]),

library/std/src/io/buffered/bufreader/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Buffer {
4848

4949
#[inline]
5050
pub fn buffer(&self) -> &[u8] {
51-
// SAFETY: self.pos and self.cap are valid, and self.cap => self.pos, and
51+
// SAFETY: self.pos and self.filled are valid, and self.filled >= self.pos, and
5252
// that region is initialized because those are all invariants of this type.
5353
unsafe { self.buf.get_unchecked(self.pos..self.filled).assume_init_ref() }
5454
}

library/std/src/io/buffered/linewritershim.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, W: ?Sized + Write> LineWriterShim<'a, W> {
5252
}
5353

5454
impl<'a, W: ?Sized + Write> Write for LineWriterShim<'a, W> {
55-
/// Writes some data into this BufReader with line buffering.
55+
/// Writes some data into this BufWriter with line buffering.
5656
///
5757
/// This means that, if any newlines are present in the data, the data up to
5858
/// the last newline is sent directly to the underlying writer, and data
@@ -146,7 +146,7 @@ impl<'a, W: ?Sized + Write> Write for LineWriterShim<'a, W> {
146146
self.buffer.flush()
147147
}
148148

149-
/// Writes some vectored data into this BufReader with line buffering.
149+
/// Writes some vectored data into this BufWriter with line buffering.
150150
///
151151
/// This means that, if any newlines are present in the data, the data up to
152152
/// and including the buffer containing the last newline is sent directly to
@@ -256,7 +256,7 @@ impl<'a, W: ?Sized + Write> Write for LineWriterShim<'a, W> {
256256
self.inner().is_write_vectored()
257257
}
258258

259-
/// Writes some data into this BufReader with line buffering.
259+
/// Writes some data into this BufWriter with line buffering.
260260
///
261261
/// This means that, if any newlines are present in the data, the data up to
262262
/// the last newline is sent directly to the underlying writer, and data

0 commit comments

Comments
 (0)