mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 22:16:53 +00:00
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
This commit is contained in:
commit
e013d8f8b3
@ -2,7 +2,7 @@ use crate::callee::{self, DeferredCallResolution};
|
||||
use crate::errors::CtorIsPrivate;
|
||||
use crate::method::{self, MethodCallee, SelfSource};
|
||||
use crate::rvalue_scopes;
|
||||
use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, RawTy};
|
||||
use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, RawTy};
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed, MultiSpan, StashKey};
|
||||
@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
format!("{:p}", self)
|
||||
}
|
||||
|
||||
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> {
|
||||
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> Ty<'tcx> {
|
||||
self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| {
|
||||
span_bug!(span, "no type for local variable {}", self.tcx.hir().node_to_string(nid))
|
||||
})
|
||||
@ -1152,7 +1152,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
);
|
||||
|
||||
if let Res::Local(hid) = res {
|
||||
let ty = self.local_ty(span, hid).decl_ty;
|
||||
let ty = self.local_ty(span, hid);
|
||||
let ty = self.normalize(span, ty);
|
||||
self.write_ty(hir_id, ty);
|
||||
return (ty, res);
|
||||
|
@ -6,8 +6,7 @@ use crate::method::MethodCallee;
|
||||
use crate::TupleArgumentsFlag::*;
|
||||
use crate::{errors, Expectation::*};
|
||||
use crate::{
|
||||
struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy, Needs, RawTy,
|
||||
TupleArgumentsFlag,
|
||||
struct_span_err, BreakableCtxt, Diverges, Expectation, FnCtxt, Needs, RawTy, TupleArgumentsFlag,
|
||||
};
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
@ -1423,7 +1422,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// See #44848.
|
||||
let ref_bindings = pat.contains_explicit_ref_binding();
|
||||
|
||||
let local_ty = self.local_ty(init.span, hir_id).revealed_ty;
|
||||
let local_ty = self.local_ty(init.span, hir_id);
|
||||
if let Some(m) = ref_bindings {
|
||||
// Somewhat subtle: if we have a `ref` binding in the pattern,
|
||||
// we want to avoid introducing coercions for the RHS. This is
|
||||
@ -1453,7 +1452,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
pub(in super::super) fn check_decl(&self, decl: Declaration<'tcx>) {
|
||||
// Determine and write the type which we'll check the pattern against.
|
||||
let decl_ty = self.local_ty(decl.span, decl.hir_id).decl_ty;
|
||||
let decl_ty = self.local_ty(decl.span, decl.hir_id);
|
||||
self.write_ty(decl.hir_id, decl_ty);
|
||||
|
||||
// Type check the initializer.
|
||||
@ -1799,9 +1798,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let err = self.tcx.ty_error(guar);
|
||||
self.write_ty(hir_id, err);
|
||||
self.write_ty(pat.hir_id, err);
|
||||
let local_ty = LocalTy { decl_ty: err, revealed_ty: err };
|
||||
self.locals.borrow_mut().insert(hir_id, local_ty);
|
||||
self.locals.borrow_mut().insert(pat.hir_id, local_ty);
|
||||
self.locals.borrow_mut().insert(hir_id, err);
|
||||
self.locals.borrow_mut().insert(pat.hir_id, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{FnCtxt, LocalTy};
|
||||
use crate::FnCtxt;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::PatKind;
|
||||
@ -48,7 +48,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
||||
Self { fcx, outermost_fn_param_pat: None }
|
||||
}
|
||||
|
||||
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
|
||||
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
|
||||
match ty_opt {
|
||||
None => {
|
||||
// Infer the variable's type.
|
||||
@ -56,23 +56,20 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
||||
kind: TypeVariableOriginKind::TypeInference,
|
||||
span,
|
||||
});
|
||||
self.fcx
|
||||
.locals
|
||||
.borrow_mut()
|
||||
.insert(nid, LocalTy { decl_ty: var_ty, revealed_ty: var_ty });
|
||||
self.fcx.locals.borrow_mut().insert(nid, var_ty);
|
||||
var_ty
|
||||
}
|
||||
Some(typ) => {
|
||||
// Take type that the user specified.
|
||||
self.fcx.locals.borrow_mut().insert(nid, typ);
|
||||
typ.revealed_ty
|
||||
typ
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Allocates a [LocalTy] for a declaration, which may have a type annotation. If it does have
|
||||
/// a type annotation, then the LocalTy stored will be the resolved type. This may be found
|
||||
/// again during type checking by querying [FnCtxt::local_ty] for the same hir_id.
|
||||
/// Allocates a type for a declaration, which may have a type annotation. If it does have
|
||||
/// a type annotation, then the [`Ty`] stored will be the resolved type. This may be found
|
||||
/// again during type checking by querying [`FnCtxt::local_ty`] for the same hir_id.
|
||||
fn declare(&mut self, decl: Declaration<'tcx>) {
|
||||
let local_ty = match decl.ty {
|
||||
Some(ref ty) => {
|
||||
@ -87,7 +84,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
||||
.user_provided_types_mut()
|
||||
.insert(ty.hir_id, c_ty);
|
||||
|
||||
Some(LocalTy { decl_ty: o_ty.normalized, revealed_ty: o_ty.normalized })
|
||||
Some(o_ty.normalized)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
@ -96,7 +93,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
||||
debug!(
|
||||
"local variable {:?} is assigned type {}",
|
||||
decl.pat,
|
||||
self.fcx.ty_to_string(self.fcx.locals.borrow().get(&decl.hir_id).unwrap().decl_ty)
|
||||
self.fcx.ty_to_string(*self.fcx.locals.borrow().get(&decl.hir_id).unwrap())
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -151,7 +148,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
debug!(
|
||||
"pattern binding {} is assigned to {} with type {:?}",
|
||||
ident,
|
||||
self.fcx.ty_to_string(self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty),
|
||||
self.fcx.ty_to_string(*self.fcx.locals.borrow().get(&p.hir_id).unwrap()),
|
||||
var_ty
|
||||
);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub struct Inherited<'tcx> {
|
||||
|
||||
pub(super) typeck_results: RefCell<ty::TypeckResults<'tcx>>,
|
||||
|
||||
pub(super) locals: RefCell<HirIdMap<super::LocalTy<'tcx>>>,
|
||||
pub(super) locals: RefCell<HirIdMap<Ty<'tcx>>>,
|
||||
|
||||
pub(super) fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,
|
||||
|
||||
|
@ -89,13 +89,6 @@ macro_rules! type_error_struct {
|
||||
})
|
||||
}
|
||||
|
||||
/// The type of a local binding, including the revealed type for anon types.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct LocalTy<'tcx> {
|
||||
decl_ty: Ty<'tcx>,
|
||||
revealed_ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
/// If this `DefId` is a "primary tables entry", returns
|
||||
/// `Some((body_id, body_ty, fn_sig))`. Otherwise, returns `None`.
|
||||
///
|
||||
|
@ -594,7 +594,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
debug!("check_pat_ident: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
|
||||
|
||||
let local_ty = self.local_ty(pat.span, pat.hir_id).decl_ty;
|
||||
let local_ty = self.local_ty(pat.span, pat.hir_id);
|
||||
let eq_ty = match bm {
|
||||
ty::BindByReference(mutbl) => {
|
||||
// If the binding is like `ref x | ref mut x`,
|
||||
@ -635,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ty: Ty<'tcx>,
|
||||
ti: TopInfo<'tcx>,
|
||||
) {
|
||||
let var_ty = self.local_ty(span, var_id).decl_ty;
|
||||
let var_ty = self.local_ty(span, var_id);
|
||||
if let Some(mut err) = self.demand_eqtype_pat_diag(span, var_ty, ty, ti) {
|
||||
let hir = self.tcx.hir();
|
||||
let var_ty = self.resolve_vars_with_obligations(var_ty);
|
||||
|
@ -348,7 +348,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
|
||||
|
||||
fn visit_local(&mut self, l: &'tcx hir::Local<'tcx>) {
|
||||
intravisit::walk_local(self, l);
|
||||
let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty;
|
||||
let var_ty = self.fcx.local_ty(l.span, l.hir_id);
|
||||
let var_ty = self.resolve(var_ty, &l.span);
|
||||
self.write_ty_to_typeck_results(l.hir_id, var_ty);
|
||||
}
|
||||
|
@ -144,8 +144,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let len = "foo".len();
|
||||
/// assert_eq!(3, len);
|
||||
@ -165,8 +163,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let s = "";
|
||||
/// assert!(s.is_empty());
|
||||
@ -311,8 +307,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let bytes = "bors".as_bytes();
|
||||
/// assert_eq!(b"bors", bytes);
|
||||
@ -387,8 +381,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let s = "Hello";
|
||||
/// let ptr = s.as_ptr();
|
||||
@ -570,8 +562,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let s = "Löwe 老虎 Léopard";
|
||||
///
|
||||
@ -649,8 +639,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let s = "Per Martin-Löf";
|
||||
///
|
||||
@ -691,8 +679,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let mut s = "Per Martin-Löf".to_string();
|
||||
/// {
|
||||
@ -840,8 +826,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let mut bytes = "bors".bytes();
|
||||
///
|
||||
@ -1020,8 +1004,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let text = "Zażółć gęślą jaźń";
|
||||
///
|
||||
@ -1050,8 +1032,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let bananas = "bananas";
|
||||
///
|
||||
@ -1077,8 +1057,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let bananas = "bananas";
|
||||
///
|
||||
@ -1103,8 +1081,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let bananas = "bananas";
|
||||
///
|
||||
@ -1463,8 +1439,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let v: Vec<&str> = "A.B.".split_terminator('.').collect();
|
||||
/// assert_eq!(v, ["A", "B"]);
|
||||
@ -1696,8 +1670,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect();
|
||||
/// assert_eq!(v, ["abc", "abc", "abc"]);
|
||||
@ -1732,8 +1704,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect();
|
||||
/// assert_eq!(v, ["abc", "abc", "abc"]);
|
||||
@ -1775,8 +1745,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let v: Vec<_> = "abcXXXabcYYYabc".match_indices("abc").collect();
|
||||
/// assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]);
|
||||
@ -1817,8 +1785,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let v: Vec<_> = "abcXXXabcYYYabc".rmatch_indices("abc").collect();
|
||||
/// assert_eq!(v, [(12, "abc"), (6, "abc"), (0, "abc")]);
|
||||
@ -1845,8 +1811,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// let s = "\n Hello\tworld\t\n";
|
||||
///
|
||||
@ -2085,8 +2049,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// assert_eq!("11foo1bar11".trim_start_matches('1'), "foo1bar11");
|
||||
/// assert_eq!("123foo1bar123".trim_start_matches(char::is_numeric), "foo1bar123");
|
||||
@ -2232,8 +2194,6 @@ impl str {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
|
||||
/// assert_eq!("123foo1bar123".trim_left_matches(char::is_numeric), "foo1bar123");
|
||||
|
@ -2543,12 +2543,12 @@ impl<'a, K, V> Entry<'a, K, V> {
|
||||
/// ```
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// let mut map: HashMap<&str, String> = HashMap::new();
|
||||
/// let s = "hoho".to_string();
|
||||
/// let mut map = HashMap::new();
|
||||
/// let value = "hoho";
|
||||
///
|
||||
/// map.entry("poneyland").or_insert_with(|| s);
|
||||
/// map.entry("poneyland").or_insert_with(|| value);
|
||||
///
|
||||
/// assert_eq!(map["poneyland"], "hoho".to_string());
|
||||
/// assert_eq!(map["poneyland"], "hoho");
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -12,6 +12,9 @@ extended = true
|
||||
[llvm]
|
||||
download-ci-llvm = false
|
||||
[rust]
|
||||
# We have several defaults in bootstrap that depend on whether the channel is `dev` (e.g. `omit-git-hash` and `download-ci-llvm`).
|
||||
# Make sure they don't get set when installing from source.
|
||||
channel = "nightly"
|
||||
download-rustc = false
|
||||
|
||||
[dist]
|
||||
|
@ -1 +1 @@
|
||||
0.16.7
|
||||
0.16.8
|
@ -5,7 +5,7 @@
|
||||
# and remove it from .git/hooks to deactivate.
|
||||
#
|
||||
|
||||
set -Eeuo pipefail
|
||||
set -Euo pipefail
|
||||
|
||||
# https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570
|
||||
unset GIT_DIR
|
||||
@ -15,3 +15,7 @@ echo "Running pre-push script $ROOT_DIR/x test tidy"
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
./x test tidy --set build.locked-deps=true
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "You may use \`git push --no-verify\` to skip this check."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -398,6 +398,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
|
||||
.doc_link_resolutions(module_id)
|
||||
.get(&(Symbol::intern(path_str), ns))
|
||||
.copied()
|
||||
// NOTE: do not remove this panic! Missing links should be recorded as `Res::Err`; if
|
||||
// `doc_link_resolutions` is missing a `path_str`, that means that there are valid links
|
||||
// that are being missed. To fix the ICE, change
|
||||
// `rustc_resolve::rustdoc::attrs_to_preprocessed_links` to cache the link.
|
||||
.unwrap_or_else(|| panic!("no resolution for {:?} {:?} {:?}", path_str, ns, module_id))
|
||||
.and_then(|res| res.try_into().ok())
|
||||
.or_else(|| resolve_primitive(path_str, ns));
|
||||
|
@ -4374,7 +4374,7 @@ impl ProcRes {
|
||||
pub fn print_info(&self) {
|
||||
fn render(name: &str, contents: &str) -> String {
|
||||
let contents = json::extract_rendered(contents);
|
||||
let contents = contents.trim();
|
||||
let contents = contents.trim_end();
|
||||
if contents.is_empty() {
|
||||
format!("{name}: none")
|
||||
} else {
|
||||
|
@ -38,10 +38,11 @@ compare-elements-position-near: (
|
||||
".search-results .result-name .path",
|
||||
{"y": 2, "x": 0},
|
||||
)
|
||||
store-size: (".search-results .result-name", {"width": width, "height": height})
|
||||
store-size: (".search-results .result-name .path", {"width": sub_width, "height": sub_height})
|
||||
assert: |width| < |sub_width| + 8 && |width| > |sub_width| - 8
|
||||
assert: |height| < |sub_height| + 8 && |height| > |sub_height| - 8
|
||||
compare-elements-size-near: (
|
||||
".search-results .result-name",
|
||||
".search-results .result-name .path",
|
||||
{"width": 8, "height": 8},
|
||||
)
|
||||
|
||||
// Check that the crate filter `<select>` is correctly handled when it goes to next line.
|
||||
// To do so we need to update the length of one of its `<option>`.
|
||||
|
Loading…
Reference in New Issue
Block a user