Skip to content

Commit e013d8f

Browse files
committed
Auto merge of #113216 - matthiaskrgr:rollup-8xe65sj, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #113072 (str docs: remove "Basic usage" text where not useful) - #113153 (make HashMap::or_insert_with example more simple) - #113185 (Set `channel = nightly` in dist profile) - #113186 (document that the panic in collect_intra_doc_links is load-bearing) - #113187 (No need to distinguish `LocalTy` from `Ty`) - #113189 (compiletest: Only trim the end of process output) - #113191 (Update browser-ui-test version and improve GUI test) - #113206 (User may want to skip tidy check sometimes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f4b80ca + 58a61ee commit e013d8f

File tree

15 files changed

+45
-85
lines changed

15 files changed

+45
-85
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::callee::{self, DeferredCallResolution};
22
use crate::errors::CtorIsPrivate;
33
use crate::method::{self, MethodCallee, SelfSource};
44
use crate::rvalue_scopes;
5-
use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, RawTy};
5+
use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, RawTy};
66
use rustc_data_structures::captures::Captures;
77
use rustc_data_structures::fx::FxHashSet;
88
use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed, MultiSpan, StashKey};
@@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
135135
format!("{:p}", self)
136136
}
137137

138-
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> {
138+
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> Ty<'tcx> {
139139
self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| {
140140
span_bug!(span, "no type for local variable {}", self.tcx.hir().node_to_string(nid))
141141
})
@@ -1152,7 +1152,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11521152
);
11531153

11541154
if let Res::Local(hid) = res {
1155-
let ty = self.local_ty(span, hid).decl_ty;
1155+
let ty = self.local_ty(span, hid);
11561156
let ty = self.normalize(span, ty);
11571157
self.write_ty(hir_id, ty);
11581158
return (ty, res);

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use crate::method::MethodCallee;
66
use crate::TupleArgumentsFlag::*;
77
use crate::{errors, Expectation::*};
88
use crate::{
9-
struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, Needs, RawTy,
10-
TupleArgumentsFlag,
9+
struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, Needs, RawTy, TupleArgumentsFlag,
1110
};
1211
use rustc_ast as ast;
1312
use rustc_data_structures::fx::FxIndexSet;
@@ -1423,7 +1422,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14231422
// See #44848.
14241423
let ref_bindings = pat.contains_explicit_ref_binding();
14251424

1426-
let local_ty = self.local_ty(init.span, hir_id).revealed_ty;
1425+
let local_ty = self.local_ty(init.span, hir_id);
14271426
if let Some(m) = ref_bindings {
14281427
// Somewhat subtle: if we have a `ref` binding in the pattern,
14291428
// we want to avoid introducing coercions for the RHS. This is
@@ -1453,7 +1452,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14531452

14541453
pub(in super::super) fn check_decl(&self, decl: Declaration<'tcx>) {
14551454
// Determine and write the type which we'll check the pattern against.
1456-
let decl_ty = self.local_ty(decl.span, decl.hir_id).decl_ty;
1455+
let decl_ty = self.local_ty(decl.span, decl.hir_id);
14571456
self.write_ty(decl.hir_id, decl_ty);
14581457

14591458
// Type check the initializer.
@@ -1799,9 +1798,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17991798
let err = self.tcx.ty_error(guar);
18001799
self.write_ty(hir_id, err);
18011800
self.write_ty(pat.hir_id, err);
1802-
let local_ty = LocalTy { decl_ty: err, revealed_ty: err };
1803-
self.locals.borrow_mut().insert(hir_id, local_ty);
1804-
self.locals.borrow_mut().insert(pat.hir_id, local_ty);
1801+
self.locals.borrow_mut().insert(hir_id, err);
1802+
self.locals.borrow_mut().insert(pat.hir_id, err);
18051803
}
18061804
}
18071805

compiler/rustc_hir_typeck/src/gather_locals.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{FnCtxt, LocalTy};
1+
use crate::FnCtxt;
22
use rustc_hir as hir;
33
use rustc_hir::intravisit::{self, Visitor};
44
use rustc_hir::PatKind;
@@ -48,31 +48,28 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
4848
Self { fcx, outermost_fn_param_pat: None }
4949
}
5050

51-
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
51+
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
5252
match ty_opt {
5353
None => {
5454
// Infer the variable's type.
5555
let var_ty = self.fcx.next_ty_var(TypeVariableOrigin {
5656
kind: TypeVariableOriginKind::TypeInference,
5757
span,
5858
});
59-
self.fcx
60-
.locals
61-
.borrow_mut()
62-
.insert(nid, LocalTy { decl_ty: var_ty, revealed_ty: var_ty });
59+
self.fcx.locals.borrow_mut().insert(nid, var_ty);
6360
var_ty
6461
}
6562
Some(typ) => {
6663
// Take type that the user specified.
6764
self.fcx.locals.borrow_mut().insert(nid, typ);
68-
typ.revealed_ty
65+
typ
6966
}
7067
}
7168
}
7269

73-
/// Allocates a [LocalTy] for a declaration, which may have a type annotation. If it does have
74-
/// a type annotation, then the LocalTy stored will be the resolved type. This may be found
75-
/// again during type checking by querying [FnCtxt::local_ty] for the same hir_id.
70+
/// Allocates a type for a declaration, which may have a type annotation. If it does have
71+
/// a type annotation, then the [`Ty`] stored will be the resolved type. This may be found
72+
/// again during type checking by querying [`FnCtxt::local_ty`] for the same hir_id.
7673
fn declare(&mut self, decl: Declaration<'tcx>) {
7774
let local_ty = match decl.ty {
7875
Some(ref ty) => {
@@ -87,7 +84,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
8784
.user_provided_types_mut()
8885
.insert(ty.hir_id, c_ty);
8986

90-
Some(LocalTy { decl_ty: o_ty.normalized, revealed_ty: o_ty.normalized })
87+
Some(o_ty.normalized)
9188
}
9289
None => None,
9390
};
@@ -96,7 +93,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
9693
debug!(
9794
"local variable {:?} is assigned type {}",
9895
decl.pat,
99-
self.fcx.ty_to_string(self.fcx.locals.borrow().get(&decl.hir_id).unwrap().decl_ty)
96+
self.fcx.ty_to_string(*self.fcx.locals.borrow().get(&decl.hir_id).unwrap())
10097
);
10198
}
10299
}
@@ -151,7 +148,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
151148
debug!(
152149
"pattern binding {} is assigned to {} with type {:?}",
153150
ident,
154-
self.fcx.ty_to_string(self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty),
151+
self.fcx.ty_to_string(*self.fcx.locals.borrow().get(&p.hir_id).unwrap()),
155152
var_ty
156153
);
157154
}

compiler/rustc_hir_typeck/src/inherited.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct Inherited<'tcx> {
3030

3131
pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,
3232

33-
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
33+
pub(super) locals: RefCell<HirIdMap<Ty<'tcx>>>,
3434

3535
pub(super) fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,
3636

compiler/rustc_hir_typeck/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ macro_rules! type_error_struct {
8989
})
9090
}
9191

92-
/// The type of a local binding, including the revealed type for anon types.
93-
#[derive(Copy, Clone, Debug)]
94-
pub struct LocalTy<'tcx> {
95-
decl_ty: Ty<'tcx>,
96-
revealed_ty: Ty<'tcx>,
97-
}
98-
9992
/// If this `DefId` is a "primary tables entry", returns
10093
/// `Some((body_id, body_ty, fn_sig))`. Otherwise, returns `None`.
10194
///

compiler/rustc_hir_typeck/src/pat.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
594594

595595
debug!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
596596

597-
let local_ty = self.local_ty(pat.span, pat.hir_id).decl_ty;
597+
let local_ty = self.local_ty(pat.span, pat.hir_id);
598598
let eq_ty = match bm {
599599
ty::BindByReference(mutbl) => {
600600
// If the binding is like `ref x | ref mut x`,
@@ -635,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
635635
ty: Ty<'tcx>,
636636
ti: TopInfo<'tcx>,
637637
) {
638-
let var_ty = self.local_ty(span, var_id).decl_ty;
638+
let var_ty = self.local_ty(span, var_id);
639639
if let Some(mut err) = self.demand_eqtype_pat_diag(span, var_ty, ty, ti) {
640640
let hir = self.tcx.hir();
641641
let var_ty = self.resolve_vars_with_obligations(var_ty);

compiler/rustc_hir_typeck/src/writeback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
348348

349349
fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
350350
intravisit::walk_local(self, l);
351-
let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty;
351+
let var_ty = self.fcx.local_ty(l.span, l.hir_id);
352352
let var_ty = self.resolve(var_ty, &l.span);
353353
self.write_ty_to_typeck_results(l.hir_id, var_ty);
354354
}

library/core/src/str/mod.rs

-40
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ impl str {
144144
///
145145
/// # Examples
146146
///
147-
/// Basic usage:
148-
///
149147
/// ```
150148
/// let len = "foo".len();
151149
/// assert_eq!(3, len);
@@ -165,8 +163,6 @@ impl str {
165163
///
166164
/// # Examples
167165
///
168-
/// Basic usage:
169-
///
170166
/// ```
171167
/// let s = "";
172168
/// assert!(s.is_empty());
@@ -311,8 +307,6 @@ impl str {
311307
///
312308
/// # Examples
313309
///
314-
/// Basic usage:
315-
///
316310
/// ```
317311
/// let bytes = "bors".as_bytes();
318312
/// assert_eq!(b"bors", bytes);
@@ -387,8 +381,6 @@ impl str {
387381
///
388382
/// # Examples
389383
///
390-
/// Basic usage:
391-
///
392384
/// ```
393385
/// let s = "Hello";
394386
/// let ptr = s.as_ptr();
@@ -570,8 +562,6 @@ impl str {
570562
///
571563
/// # Examples
572564
///
573-
/// Basic usage:
574-
///
575565
/// ```
576566
/// let s = "Löwe 老虎 Léopard";
577567
///
@@ -649,8 +639,6 @@ impl str {
649639
///
650640
/// # Examples
651641
///
652-
/// Basic usage:
653-
///
654642
/// ```
655643
/// let s = "Per Martin-Löf";
656644
///
@@ -691,8 +679,6 @@ impl str {
691679
///
692680
/// # Examples
693681
///
694-
/// Basic usage:
695-
///
696682
/// ```
697683
/// let mut s = "Per Martin-Löf".to_string();
698684
/// {
@@ -840,8 +826,6 @@ impl str {
840826
///
841827
/// # Examples
842828
///
843-
/// Basic usage:
844-
///
845829
/// ```
846830
/// let mut bytes = "bors".bytes();
847831
///
@@ -1020,8 +1004,6 @@ impl str {
10201004
///
10211005
/// # Examples
10221006
///
1023-
/// Basic usage:
1024-
///
10251007
/// ```
10261008
/// let text = "Zażółć gęślą jaźń";
10271009
///
@@ -1050,8 +1032,6 @@ impl str {
10501032
///
10511033
/// # Examples
10521034
///
1053-
/// Basic usage:
1054-
///
10551035
/// ```
10561036
/// let bananas = "bananas";
10571037
///
@@ -1077,8 +1057,6 @@ impl str {
10771057
///
10781058
/// # Examples
10791059
///
1080-
/// Basic usage:
1081-
///
10821060
/// ```
10831061
/// let bananas = "bananas";
10841062
///
@@ -1103,8 +1081,6 @@ impl str {
11031081
///
11041082
/// # Examples
11051083
///
1106-
/// Basic usage:
1107-
///
11081084
/// ```
11091085
/// let bananas = "bananas";
11101086
///
@@ -1463,8 +1439,6 @@ impl str {
14631439
///
14641440
/// # Examples
14651441
///
1466-
/// Basic usage:
1467-
///
14681442
/// ```
14691443
/// let v: Vec<&str> = "A.B.".split_terminator('.').collect();
14701444
/// assert_eq!(v, ["A", "B"]);
@@ -1696,8 +1670,6 @@ impl str {
16961670
///
16971671
/// # Examples
16981672
///
1699-
/// Basic usage:
1700-
///
17011673
/// ```
17021674
/// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect();
17031675
/// assert_eq!(v, ["abc", "abc", "abc"]);
@@ -1732,8 +1704,6 @@ impl str {
17321704
///
17331705
/// # Examples
17341706
///
1735-
/// Basic usage:
1736-
///
17371707
/// ```
17381708
/// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect();
17391709
/// assert_eq!(v, ["abc", "abc", "abc"]);
@@ -1775,8 +1745,6 @@ impl str {
17751745
///
17761746
/// # Examples
17771747
///
1778-
/// Basic usage:
1779-
///
17801748
/// ```
17811749
/// let v: Vec<_> = "abcXXXabcYYYabc".match_indices("abc").collect();
17821750
/// assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]);
@@ -1817,8 +1785,6 @@ impl str {
18171785
///
18181786
/// # Examples
18191787
///
1820-
/// Basic usage:
1821-
///
18221788
/// ```
18231789
/// let v: Vec<_> = "abcXXXabcYYYabc".rmatch_indices("abc").collect();
18241790
/// assert_eq!(v, [(12, "abc"), (6, "abc"), (0, "abc")]);
@@ -1845,8 +1811,6 @@ impl str {
18451811
///
18461812
/// # Examples
18471813
///
1848-
/// Basic usage:
1849-
///
18501814
/// ```
18511815
/// let s = "\n Hello\tworld\t\n";
18521816
///
@@ -2085,8 +2049,6 @@ impl str {
20852049
///
20862050
/// # Examples
20872051
///
2088-
/// Basic usage:
2089-
///
20902052
/// ```
20912053
/// assert_eq!("11foo1bar11".trim_start_matches('1'), "foo1bar11");
20922054
/// assert_eq!("123foo1bar123".trim_start_matches(char::is_numeric), "foo1bar123");
@@ -2232,8 +2194,6 @@ impl str {
22322194
///
22332195
/// # Examples
22342196
///
2235-
/// Basic usage:
2236-
///
22372197
/// ```
22382198
/// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
22392199
/// assert_eq!("123foo1bar123".trim_left_matches(char::is_numeric), "foo1bar123");

library/std/src/collections/hash/map.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2543,12 +2543,12 @@ impl<'a, K, V> Entry<'a, K, V> {
25432543
/// ```
25442544
/// use std::collections::HashMap;
25452545
///
2546-
/// let mut map: HashMap<&str, String> = HashMap::new();
2547-
/// let s = "hoho".to_string();
2546+
/// let mut map = HashMap::new();
2547+
/// let value = "hoho";
25482548
///
2549-
/// map.entry("poneyland").or_insert_with(|| s);
2549+
/// map.entry("poneyland").or_insert_with(|| value);
25502550
///
2551-
/// assert_eq!(map["poneyland"], "hoho".to_string());
2551+
/// assert_eq!(map["poneyland"], "hoho");
25522552
/// ```
25532553
#[inline]
25542554
#[stable(feature = "rust1", since = "1.0.0")]

src/bootstrap/defaults/config.dist.toml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ extended = true
1212
[llvm]
1313
download-ci-llvm = false
1414
[rust]
15+
# We have several defaults in bootstrap that depend on whether the channel is `dev` (e.g. `omit-git-hash` and `download-ci-llvm`).
16+
# Make sure they don't get set when installing from source.
17+
channel = "nightly"
1518
download-rustc = false
1619

1720
[dist]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.16.7
1+
0.16.8

0 commit comments

Comments
 (0)