Skip to content

Commit 81eb152

Browse files
committed
Auto merge of #61527 - pietroalbini:rollup-vhxyqlk, r=pietroalbini
Rollup of 5 pull requests Successful merges: - #61069 (Make MIR drop terminators borrow the dropped location) - #61453 (Remove unneeded feature attr from atomic integers doctests) - #61488 (Fix NLL typeck ICEs) - #61500 (Fix regression 61475) - #61523 (Hide gen_future API from documentation) Failed merges: r? @ghost
2 parents 5d8f59f + e83dceb commit 81eb152

File tree

12 files changed

+274
-22
lines changed

12 files changed

+274
-22
lines changed

src/libcore/sync/atomic.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ atomic_int! {
18991899
stable(feature = "integer_atomics_stable", since = "1.34.0"),
19001900
unstable(feature = "integer_atomics", issue = "32976"),
19011901
"i8", "../../../std/primitive.i8.html",
1902-
"#![feature(integer_atomics)]\n\n",
1902+
"",
19031903
atomic_min, atomic_max,
19041904
1,
19051905
"AtomicI8::new(0)",
@@ -1915,7 +1915,7 @@ atomic_int! {
19151915
stable(feature = "integer_atomics_stable", since = "1.34.0"),
19161916
unstable(feature = "integer_atomics", issue = "32976"),
19171917
"u8", "../../../std/primitive.u8.html",
1918-
"#![feature(integer_atomics)]\n\n",
1918+
"",
19191919
atomic_umin, atomic_umax,
19201920
1,
19211921
"AtomicU8::new(0)",
@@ -1931,7 +1931,7 @@ atomic_int! {
19311931
stable(feature = "integer_atomics_stable", since = "1.34.0"),
19321932
unstable(feature = "integer_atomics", issue = "32976"),
19331933
"i16", "../../../std/primitive.i16.html",
1934-
"#![feature(integer_atomics)]\n\n",
1934+
"",
19351935
atomic_min, atomic_max,
19361936
2,
19371937
"AtomicI16::new(0)",
@@ -1947,7 +1947,7 @@ atomic_int! {
19471947
stable(feature = "integer_atomics_stable", since = "1.34.0"),
19481948
unstable(feature = "integer_atomics", issue = "32976"),
19491949
"u16", "../../../std/primitive.u16.html",
1950-
"#![feature(integer_atomics)]\n\n",
1950+
"",
19511951
atomic_umin, atomic_umax,
19521952
2,
19531953
"AtomicU16::new(0)",
@@ -1963,7 +1963,7 @@ atomic_int! {
19631963
stable(feature = "integer_atomics_stable", since = "1.34.0"),
19641964
unstable(feature = "integer_atomics", issue = "32976"),
19651965
"i32", "../../../std/primitive.i32.html",
1966-
"#![feature(integer_atomics)]\n\n",
1966+
"",
19671967
atomic_min, atomic_max,
19681968
4,
19691969
"AtomicI32::new(0)",
@@ -1979,7 +1979,7 @@ atomic_int! {
19791979
stable(feature = "integer_atomics_stable", since = "1.34.0"),
19801980
unstable(feature = "integer_atomics", issue = "32976"),
19811981
"u32", "../../../std/primitive.u32.html",
1982-
"#![feature(integer_atomics)]\n\n",
1982+
"",
19831983
atomic_umin, atomic_umax,
19841984
4,
19851985
"AtomicU32::new(0)",
@@ -1995,7 +1995,7 @@ atomic_int! {
19951995
stable(feature = "integer_atomics_stable", since = "1.34.0"),
19961996
unstable(feature = "integer_atomics", issue = "32976"),
19971997
"i64", "../../../std/primitive.i64.html",
1998-
"#![feature(integer_atomics)]\n\n",
1998+
"",
19991999
atomic_min, atomic_max,
20002000
8,
20012001
"AtomicI64::new(0)",
@@ -2011,7 +2011,7 @@ atomic_int! {
20112011
stable(feature = "integer_atomics_stable", since = "1.34.0"),
20122012
unstable(feature = "integer_atomics", issue = "32976"),
20132013
"u64", "../../../std/primitive.u64.html",
2014-
"#![feature(integer_atomics)]\n\n",
2014+
"",
20152015
atomic_umin, atomic_umax,
20162016
8,
20172017
"AtomicU64::new(0)",

src/librustc/infer/canonical/canonicalizer.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,17 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
115115

116116
/// A hacky variant of `canonicalize_query` that does not
117117
/// canonicalize `'static`. Unfortunately, the existing leak
118-
/// check treaks `'static` differently in some cases (see also
118+
/// check treats `'static` differently in some cases (see also
119119
/// #33684), so if we are performing an operation that may need to
120120
/// prove "leak-check" related things, we leave `'static`
121121
/// alone.
122+
///
123+
/// `'static` is also special cased when winnowing candidates when
124+
/// selecting implementation candidates, so we also have to leave `'static`
125+
/// alone for queries that do selection.
122126
//
123-
// FIXME(#48536): once we have universes, we can remove this and just use
124-
// `canonicalize_query`.
127+
// FIXME(#48536): once the above issues are resolved, we can remove this
128+
// and just use `canonicalize_query`.
125129
pub fn canonicalize_hr_query_hack<V>(
126130
&self,
127131
value: &V,

src/librustc/traits/query/normalize.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
145145
let gcx = self.infcx.tcx.global_tcx();
146146

147147
let mut orig_values = OriginalQueryValues::default();
148-
let c_data = self.infcx.canonicalize_query(
148+
// HACK(matthewjasper) `'static` is special-cased in selection,
149+
// so we cannot canonicalize it.
150+
let c_data = self.infcx.canonicalize_hr_query_hack(
149151
&self.param_env.and(*data), &mut orig_values);
150152
debug!("QueryNormalizer: c_data = {:#?}", c_data);
151153
debug!("QueryNormalizer: orig_values = {:#?}", orig_values);

src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs

+7
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
334334

335335
match outlives_bound {
336336
OutlivesBound::RegionSubRegion(r1, r2) => {
337+
// `where Type:` is lowered to `where Type: 'empty` so that
338+
// we check `Type` is well formed, but there's no use for
339+
// this bound here.
340+
if let ty::ReEmpty = r1 {
341+
return;
342+
}
343+
337344
// The bound says that `r1 <= r2`; we store `r2: r1`.
338345
let r1 = self.universal_regions.to_region_vid(r1);
339346
let r2 = self.universal_regions.to_region_vid(r2);

src/librustc_mir/dataflow/impls/borrowed_locals.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,20 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> {
5656
fn terminator_effect(&self,
5757
sets: &mut BlockSets<'_, Local>,
5858
loc: Location) {
59+
let terminator = self.mir[loc.block].terminator();
5960
BorrowedLocalsVisitor {
6061
sets,
61-
}.visit_terminator(self.mir[loc.block].terminator(), loc);
62+
}.visit_terminator(terminator, loc);
63+
match &terminator.kind {
64+
// Drop terminators borrows the location
65+
TerminatorKind::Drop { location, .. } |
66+
TerminatorKind::DropAndReplace { location, .. } => {
67+
if let Some(local) = find_local(location) {
68+
sets.gen(local);
69+
}
70+
}
71+
_ => (),
72+
}
6273
}
6374

6475
fn propagate_call_return(

src/libstd/future.rs

+6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ pub use core::future::*;
1616
///
1717
/// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give
1818
/// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`).
19+
#[doc(hidden)]
1920
#[unstable(feature = "gen_future", issue = "50547")]
2021
pub fn from_generator<T: Generator<Yield = ()>>(x: T) -> impl Future<Output = T::Return> {
2122
GenFuture(x)
2223
}
2324

2425
/// A wrapper around generators used to implement `Future` for `async`/`await` code.
26+
#[doc(hidden)]
2527
#[unstable(feature = "gen_future", issue = "50547")]
2628
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
2729
struct GenFuture<T: Generator<Yield = ()>>(T);
@@ -30,6 +32,7 @@ struct GenFuture<T: Generator<Yield = ()>>(T);
3032
// self-referential borrows in the underlying generator.
3133
impl<T: Generator<Yield = ()>> !Unpin for GenFuture<T> {}
3234

35+
#[doc(hidden)]
3336
#[unstable(feature = "gen_future", issue = "50547")]
3437
impl<T: Generator<Yield = ()>> Future for GenFuture<T> {
3538
type Output = T::Return;
@@ -57,6 +60,7 @@ impl Drop for SetOnDrop {
5760
}
5861
}
5962

63+
#[doc(hidden)]
6064
#[unstable(feature = "gen_future", issue = "50547")]
6165
/// Sets the thread-local task context used by async/await futures.
6266
pub fn set_task_context<F, R>(cx: &mut Context<'_>, f: F) -> R
@@ -74,6 +78,7 @@ where
7478
f()
7579
}
7680

81+
#[doc(hidden)]
7782
#[unstable(feature = "gen_future", issue = "50547")]
7883
/// Retrieves the thread-local task context used by async/await futures.
7984
///
@@ -105,6 +110,7 @@ where
105110
unsafe { f(cx_ptr.as_mut()) }
106111
}
107112

113+
#[doc(hidden)]
108114
#[unstable(feature = "gen_future", issue = "50547")]
109115
/// Polls a future in the current thread-local task waker.
110116
pub fn poll_with_tls_context<F>(f: Pin<&mut F>) -> Poll<F::Output>

src/libsyntax/parse/parser.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,10 @@ impl<'a> Parser<'a> {
628628
}
629629
_ => {
630630
Err(if self.prev_token_kind == PrevTokenKind::DocComment {
631-
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
632-
} else {
633-
self.expected_ident_found()
634-
})
631+
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
632+
} else {
633+
self.expected_ident_found()
634+
})
635635
}
636636
}
637637
}
@@ -1657,8 +1657,8 @@ impl<'a> Parser<'a> {
16571657
path = self.parse_path(PathStyle::Type)?;
16581658
path_span = path_lo.to(self.prev_span);
16591659
} else {
1660-
path = ast::Path { segments: Vec::new(), span: DUMMY_SP };
16611660
path_span = self.span.to(self.span);
1661+
path = ast::Path { segments: Vec::new(), span: path_span };
16621662
}
16631663

16641664
// See doc comment for `unmatched_angle_bracket_count`.
@@ -2844,7 +2844,11 @@ impl<'a> Parser<'a> {
28442844
// want to keep their span info to improve diagnostics in these cases in a later stage.
28452845
(true, Some(AssocOp::Multiply)) | // `{ 42 } *foo = bar;` or `{ 42 } * 3`
28462846
(true, Some(AssocOp::Subtract)) | // `{ 42 } -5`
2847-
(true, Some(AssocOp::Add)) => { // `{ 42 } + 42
2847+
(true, Some(AssocOp::LAnd)) | // `{ 42 } &&x` (#61475)
2848+
(true, Some(AssocOp::Add)) // `{ 42 } + 42
2849+
// If the next token is a keyword, then the tokens above *are* unambiguously incorrect:
2850+
// `if x { a } else { b } && if y { c } else { d }`
2851+
if !self.look_ahead(1, |t| t.is_reserved_ident()) => {
28482852
// These cases are ambiguous and can't be identified in the parser alone
28492853
let sp = self.sess.source_map().start_point(self.span);
28502854
self.sess.ambiguous_block_expr_parse.borrow_mut().insert(sp, lhs.span);
@@ -5298,7 +5302,7 @@ impl<'a> Parser<'a> {
52985302
let mut where_clause = WhereClause {
52995303
id: ast::DUMMY_NODE_ID,
53005304
predicates: Vec::new(),
5301-
span: DUMMY_SP,
5305+
span: self.prev_span.to(self.prev_span),
53025306
};
53035307

53045308
if !self.eat_keyword(kw::Where) {

src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(integer_atomics)]
2-
31
// compile-pass
42

53
use std::cell::UnsafeCell;

src/test/ui/issues/issue-61475.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// run-pass
2+
#![allow(dead_code)]
3+
4+
enum E {
5+
A, B
6+
}
7+
8+
fn main() {
9+
match &&E::A {
10+
&&E::A => {
11+
}
12+
&&E::B => {
13+
}
14+
};
15+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Regression test for #61315
2+
//
3+
// `dyn T:` is lowered to `dyn T: ReEmpty` - check that we don't ICE in NLL for
4+
// the unexpected region.
5+
6+
// compile-pass
7+
8+
trait T {}
9+
fn f() where dyn T: {}
10+
11+
fn main() {}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Regression test for #61311
2+
// We would ICE after failing to normalize `Self::Proj` in the `impl` below.
3+
4+
// compile-pass
5+
6+
pub struct Unit;
7+
trait Obj {}
8+
9+
trait Bound {}
10+
impl Bound for Unit {}
11+
12+
pub trait HasProj {
13+
type Proj;
14+
}
15+
16+
impl<T> HasProj for T {
17+
type Proj = Unit;
18+
}
19+
20+
trait HasProjFn {
21+
type Proj;
22+
fn the_fn(_: Self::Proj);
23+
}
24+
25+
impl HasProjFn for Unit
26+
where
27+
Box<dyn Obj + 'static>: HasProj,
28+
<Box<dyn Obj + 'static> as HasProj>::Proj: Bound,
29+
{
30+
type Proj = Unit;
31+
fn the_fn(_: Self::Proj) {}
32+
}
33+
34+
fn main() {}

0 commit comments

Comments
 (0)