Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #72245

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d80ac14
Extend rustdoc-js tester to allow to test multiple queries in one file
GuillaumeGomez Apr 30, 2020
7590c39
Improve doc alias JS code
GuillaumeGomez Apr 30, 2020
cf41b1d
Improve doc alias discovery
GuillaumeGomez Apr 30, 2020
3a0727e
Add more tests for doc aliases
GuillaumeGomez Apr 30, 2020
9697c46
Update std tests
GuillaumeGomez Apr 30, 2020
f581cf7
Merge aliases and search-index
GuillaumeGomez May 4, 2020
ce915f5
remove extra space from crate-level doctest names
euclio May 13, 2020
883c177
Move doc alias discovery into the Attributes struct and some code imp…
GuillaumeGomez May 4, 2020
c4d9318
Make current crate aliases go first
GuillaumeGomez May 7, 2020
e17ac66
* Update aliases data struct from HashMap to BTreeMap to have more de…
GuillaumeGomez May 13, 2020
8954379
make sure even unleashed miri does not do pointer stuff
RalfJung May 14, 2020
e84b379
[const-prop] Don't replace Rvalues that are already constants
wesleywiser Apr 23, 2020
257e377
doc: add links to rotate_(left|right)
tesuji May 15, 2020
00268be
Remove lang_items\(\).*\.unwrap\(\)
doctorn May 14, 2020
45ee336
Fix {:#?} representation of proc_macro::Literal
dtolnay May 15, 2020
4c4b4c4
Add test of proc_macro::TokenStream's Debug
dtolnay May 15, 2020
bea2c59
Clarify use of format_args in Debug for Literal
dtolnay May 15, 2020
bfdd000
Rollup merge of #71724 - GuillaumeGomez:doc-alias-improvements, r=oll…
Dylan-DPC May 15, 2020
05cf6a1
Rollup merge of #72180 - euclio:rustdoc-test-extra-space, r=Dylan-DPC
Dylan-DPC May 15, 2020
6105499
Rollup merge of #72216 - doctorn:require-lang-item, r=lcnr
Dylan-DPC May 15, 2020
d02484e
Rollup merge of #72218 - RalfJung:test-unleashed-ptrs, r=oli-obk
Dylan-DPC May 15, 2020
ec0fdfc
Rollup merge of #72220 - wesleywiser:const_prop_eval_consts, r=oli-obk
Dylan-DPC May 15, 2020
4a85552
Rollup merge of #72224 - lzutao:links, r=Dylan-DPC
Dylan-DPC May 15, 2020
707625b
Rollup merge of #72233 - dtolnay:literal, r=petrochenkov
Dylan-DPC May 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,8 @@ any high-order bits of `rhs` that would cause the shift to exceed the bitwidth o

Note that this is *not* the same as a rotate-left; the RHS of a wrapping shift-left is restricted to
the range of the type, rather than the bits shifted out of the LHS being returned to the other end.
The primitive integer types all implement a `rotate_left` function, which may be what you want
instead.
The primitive integer types all implement a `[`rotate_left`](#method.rotate_left) function,
which may be what you want instead.

# Examples

Expand Down Expand Up @@ -1531,8 +1531,8 @@ removes any high-order bits of `rhs` that would cause the shift to exceed the bi

Note that this is *not* the same as a rotate-right; the RHS of a wrapping shift-right is restricted
to the range of the type, rather than the bits shifted out of the LHS being returned to the other
end. The primitive integer types all implement a `rotate_right` function, which may be what you want
instead.
end. The primitive integer types all implement a [`rotate_right`](#method.rotate_right) function,
which may be what you want instead.

# Examples

Expand Down Expand Up @@ -3610,8 +3610,8 @@ Note that this is *not* the same as a rotate-left; the
RHS of a wrapping shift-left is restricted to the range
of the type, rather than the bits shifted out of the LHS
being returned to the other end. The primitive integer
types all implement a `rotate_left` function, which may
be what you want instead.
types all implement a [`rotate_left`](#method.rotate_left) function,
which may be what you want instead.

# Examples

Expand Down Expand Up @@ -3644,8 +3644,8 @@ Note that this is *not* the same as a rotate-right; the
RHS of a wrapping shift-right is restricted to the range
of the type, rather than the bits shifted out of the LHS
being returned to the other end. The primitive integer
types all implement a `rotate_right` function, which may
be what you want instead.
types all implement a [`rotate_right`](#method.rotate_right) function,
which may be what you want instead.

# Examples

Expand Down
10 changes: 8 additions & 2 deletions src/libproc_macro/bridge/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,16 @@ impl Clone for Literal {
}
}

// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
impl fmt::Debug for Literal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.debug())
f.debug_struct("Literal")
// format the kind without quotes, as in `kind: Float`
.field("kind", &format_args!("{}", &self.debug_kind()))
.field("symbol", &self.symbol())
// format `Some("...")` on one line even in {:#?} mode
.field("suffix", &format_args!("{:?}", &self.suffix()))
.field("span", &self.span())
.finish()
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/libproc_macro/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ macro_rules! with_api {
Literal {
fn drop($self: $S::Literal);
fn clone($self: &$S::Literal) -> $S::Literal;
// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
fn debug($self: &$S::Literal) -> String;
fn debug_kind($self: &$S::Literal) -> String;
fn symbol($self: &$S::Literal) -> String;
fn suffix($self: &$S::Literal) -> Option<String>;
fn integer(n: &str) -> $S::Literal;
fn typed_integer(n: &str, kind: &str) -> $S::Literal;
fn float(n: &str) -> $S::Literal;
Expand Down
1 change: 0 additions & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,6 @@ impl fmt::Display for Literal {
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
impl fmt::Debug for Literal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
self.0.fmt(f)
}
}
11 changes: 8 additions & 3 deletions src/librustc_expand/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,14 @@ impl server::Ident for Rustc<'_> {
}

impl server::Literal for Rustc<'_> {
// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
fn debug(&mut self, literal: &Self::Literal) -> String {
format!("{:?}", literal)
fn debug_kind(&mut self, literal: &Self::Literal) -> String {
format!("{:?}", literal.lit.kind)
}
fn symbol(&mut self, literal: &Self::Literal) -> String {
literal.lit.symbol.to_string()
}
fn suffix(&mut self, literal: &Self::Literal) -> Option<String> {
literal.lit.suffix.as_ref().map(Symbol::to_string)
}
fn integer(&mut self, n: &str) -> Self::Literal {
self.lit(token::Integer, Symbol::intern(n), None)
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir/monomorphize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use rustc_middle::traits;
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
use rustc_middle::ty::{self, Ty, TyCtxt};

use rustc_hir::lang_items::CoerceUnsizedTraitLangItem;

pub mod collector;
pub mod partitioning;

Expand All @@ -10,7 +12,7 @@ pub fn custom_coerce_unsize_info<'tcx>(
source_ty: Ty<'tcx>,
target_ty: Ty<'tcx>,
) -> CustomCoerceUnsized {
let def_id = tcx.lang_items().coerce_unsized_trait().unwrap();
let def_id = tcx.require_lang_item(CoerceUnsizedTraitLangItem, None);

let trait_ref = ty::Binder::bind(ty::TraitRef {
def_id,
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
value: OpTy<'tcx>,
source_info: SourceInfo,
) {
if let Rvalue::Use(Operand::Constant(c)) = rval {
if !matches!(c.literal.val, ConstKind::Unevaluated(..)) {
trace!("skipping replace of Rvalue::Use({:?} because it is already a const", c);
return;
}
}

trace!("attepting to replace {:?} with {:?}", rval, value);
if let Err(e) = self.ecx.const_validate_operand(
value,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_mir_build/hair/pattern/const_to_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
// code at the moment, because types like `for <'a> fn(&'a ())` do
// not *yet* implement `PartialEq`. So for now we leave this here.
let ty_is_partial_eq: bool = {
let partial_eq_trait_id = self.tcx().require_lang_item(EqTraitLangItem, None);
let partial_eq_trait_id =
self.tcx().require_lang_item(EqTraitLangItem, Some(self.span));
let obligation: PredicateObligation<'_> = predicate_for_trait_def(
self.tcx(),
self.param_env,
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_trait_selection/traits/structural_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::traits::{self, ConstPatternStructural, TraitEngine};

use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::lang_items::{StructuralPeqTraitLangItem, StructuralTeqTraitLangItem};
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeFoldable, TypeVisitor};
use rustc_span::Span;

Expand Down Expand Up @@ -69,7 +70,7 @@ pub fn type_marked_structural(
let mut fulfillment_cx = traits::FulfillmentContext::new();
let cause = ObligationCause::new(span, id, ConstPatternStructural);
// require `#[derive(PartialEq)]`
let structural_peq_def_id = infcx.tcx.lang_items().structural_peq_trait().unwrap();
let structural_peq_def_id = infcx.tcx.require_lang_item(StructuralPeqTraitLangItem, Some(span));
fulfillment_cx.register_bound(
infcx,
ty::ParamEnv::empty(),
Expand All @@ -80,7 +81,7 @@ pub fn type_marked_structural(
// for now, require `#[derive(Eq)]`. (Doing so is a hack to work around
// the type `for<'a> fn(&'a ())` failing to implement `Eq` itself.)
let cause = ObligationCause::new(span, id, ConstPatternStructural);
let structural_teq_def_id = infcx.tcx.lang_items().structural_teq_trait().unwrap();
let structural_teq_def_id = infcx.tcx.require_lang_item(StructuralTeqTraitLangItem, Some(span));
fulfillment_cx.register_bound(
infcx,
ty::ParamEnv::empty(),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::astconv::AstConv;
use crate::middle::region;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items;
use rustc_hir::lang_items::{FutureTraitLangItem, GeneratorTraitLangItem};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::LateBoundRegionConversionTime;
use rustc_infer::infer::{InferOk, InferResult};
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let trait_ref = projection.to_poly_trait_ref(tcx);

let is_fn = tcx.fn_trait_kind_from_lang_item(trait_ref.def_id()).is_some();
let gen_trait = tcx.require_lang_item(lang_items::GeneratorTraitLangItem, cause_span);
let gen_trait = tcx.require_lang_item(GeneratorTraitLangItem, cause_span);
let is_gen = gen_trait == trait_ref.def_id();
if !is_fn && !is_gen {
debug!("deduce_sig_from_projection: not fn or generator");
Expand Down Expand Up @@ -678,7 +678,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// Check that this is a projection from the `Future` trait.
let trait_ref = predicate.projection_ty.trait_ref(self.tcx);
let future_trait = self.tcx.lang_items().future_trait().unwrap();
let future_trait = self.tcx.require_lang_item(FutureTraitLangItem, Some(cause_span));
if trait_ref.def_id != future_trait {
debug!("deduce_future_output_from_projection: not a future");
return None;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_typeck/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_trait_selection::traits::{self, ObligationCause};
use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::lang_items::DerefTraitLangItem;
use rustc_hir::lang_items::{CloneTraitLangItem, DerefTraitLangItem};
use rustc_hir::{is_range_literal, Node};
use rustc_middle::ty::adjustment::AllowTwoPhase;
use rustc_middle::ty::{self, AssocItem, Ty, TypeAndMut};
Expand Down Expand Up @@ -456,8 +456,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
if self.can_coerce(ref_ty, expected) {
let mut sugg_sp = sp;
if let hir::ExprKind::MethodCall(segment, _sp, args) = &expr.kind {
let clone_trait = self.tcx.lang_items().clone_trait().unwrap();
if let hir::ExprKind::MethodCall(ref segment, sp, ref args) = expr.kind {
let clone_trait = self.tcx.require_lang_item(CloneTraitLangItem, Some(sp));
if let ([arg], Some(true), sym::clone) = (
&args[..],
self.tables.borrow().type_dependent_def_id(expr.hir_id).map(|did| {
Expand Down Expand Up @@ -635,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ if sp == expr.span && !is_macro => {
// Check for `Deref` implementations by constructing a predicate to
// prove: `<T as Deref>::Output == U`
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(expr.span));
let deref_trait = self.tcx.require_lang_item(DerefTraitLangItem, Some(sp));
let item_def_id = self
.tcx
.associated_items(deref_trait)
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::lang_items;
use rustc_hir::lang_items::{
FutureTraitLangItem, PinTypeLangItem, SizedTraitLangItem, VaListTypeLangItem,
};
use rustc_hir::{ExprKind, GenericArg, HirIdMap, Item, ItemKind, Node, PatKind, QPath};
use rustc_index::bit_set::BitSet;
use rustc_index::vec::Idx;
Expand Down Expand Up @@ -1335,10 +1337,8 @@ fn check_fn<'a, 'tcx>(
// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
// (as it's created inside the body itself, not passed in from outside).
let maybe_va_list = if fn_sig.c_variadic {
let va_list_did = tcx.require_lang_item(
lang_items::VaListTypeLangItem,
Some(body.params.last().unwrap().span),
);
let va_list_did =
tcx.require_lang_item(VaListTypeLangItem, Some(body.params.last().unwrap().span));
let region = tcx.mk_region(ty::ReScope(region::Scope {
id: body.value.hir_id.local_id,
data: region::ScopeData::CallSite,
Expand Down Expand Up @@ -3296,7 +3296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
code: traits::ObligationCauseCode<'tcx>,
) {
if !ty.references_error() {
let lang_item = self.tcx.require_lang_item(lang_items::SizedTraitLangItem, None);
let lang_item = self.tcx.require_lang_item(SizedTraitLangItem, None);
self.require_type_meets(ty, span, code, lang_item);
}
}
Expand Down Expand Up @@ -5135,7 +5135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => {}
}
let boxed_found = self.tcx.mk_box(found);
let new_found = self.tcx.mk_lang_item(boxed_found, lang_items::PinTypeLangItem).unwrap();
let new_found = self.tcx.mk_lang_item(boxed_found, PinTypeLangItem).unwrap();
if let (true, Ok(snippet)) = (
self.can_coerce(new_found, expected),
self.sess().source_map().span_to_snippet(expr.span),
Expand Down Expand Up @@ -5291,7 +5291,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let sp = expr.span;
// Check for `Future` implementations by constructing a predicate to
// prove: `<T as Future>::Output == U`
let future_trait = self.tcx.lang_items().future_trait().unwrap();
let future_trait = self.tcx.require_lang_item(FutureTraitLangItem, Some(sp));
let item_def_id = self
.tcx
.associated_items(future_trait)
Expand Down
19 changes: 11 additions & 8 deletions src/librustc_typeck/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::UnsizeTraitLangItem;
use rustc_hir::lang_items::{
CoerceUnsizedTraitLangItem, DispatchFromDynTraitLangItem, UnsizeTraitLangItem,
};
use rustc_hir::ItemKind;
use rustc_infer::infer;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
Expand Down Expand Up @@ -145,11 +147,11 @@ fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: LocalDefI
fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did);

let dispatch_from_dyn_trait = tcx.lang_items().dispatch_from_dyn_trait().unwrap();

let impl_hir_id = tcx.hir().as_local_hir_id(impl_did);
let span = tcx.hir().span(impl_hir_id);

let dispatch_from_dyn_trait = tcx.require_lang_item(DispatchFromDynTraitLangItem, Some(span));

let source = tcx.type_of(impl_did);
assert!(!source.has_escaping_bound_vars());
let target = {
Expand Down Expand Up @@ -314,22 +316,23 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef

pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did);
let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap();

// this provider should only get invoked for local def-ids
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did.expect_local());
let span = tcx.hir().span(impl_hir_id);

let coerce_unsized_trait = tcx.require_lang_item(CoerceUnsizedTraitLangItem, Some(span));

let unsize_trait = tcx.lang_items().require(UnsizeTraitLangItem).unwrap_or_else(|err| {
tcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err));
});

// this provider should only get invoked for local def-ids
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did.expect_local());

let source = tcx.type_of(impl_did);
let trait_ref = tcx.impl_trait_ref(impl_did).unwrap();
assert_eq!(trait_ref.def_id, coerce_unsized_trait);
let target = trait_ref.substs.type_at(1);
debug!("visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)", source, target);

let span = tcx.hir().span(impl_hir_id);
let param_env = tcx.param_env(impl_did);
assert!(!source.has_escaping_bound_vars());

Expand Down
9 changes: 9 additions & 0 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,15 @@ impl Attributes {
})
.collect()
}

pub fn get_doc_aliases(&self) -> FxHashSet<String> {
self.other_attrs
.lists(sym::doc)
.filter(|a| a.check_name(sym::alias))
.filter_map(|a| a.value_str().map(|s| s.to_string().replace("\"", "")))
.filter(|v| !v.is_empty())
.collect::<FxHashSet<_>>()
}
}

impl PartialEq for Attributes {
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub fn render<T: Print, S: Print>(
window.rootPath = \"{root_path}\";\
window.currentCrate = \"{krate}\";\
</script>\
<script src=\"{root_path}aliases{suffix}.js\"></script>\
<script src=\"{static_root_path}main{suffix}.js\"></script>\
{static_extra_scripts}\
{extra_scripts}\
Expand Down
Loading