Skip to content

Commit d8ffcf3

Browse files
committed
remove namespace check in nameres
1 parent f06fabc commit d8ffcf3

File tree

12 files changed

+159
-15
lines changed

12 files changed

+159
-15
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// pub type HirDelayedLint = (
2+
// &'static Lint,
3+
// HirId,
4+
// Span,
5+
// Box<dyn DynSend + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>) + 'static>,
6+
// );
7+
8+
use rustc_span::Span;
9+
10+
pub enum AttributeLintKind {
11+
UnusedDuplicate { unused: Span, used: Span, warning: bool },
12+
}
13+
14+
pub struct AttributeLint<Id> {
15+
pub id: Id,
16+
pub kind: AttributeLintKind,
17+
}

compiler/rustc_hir_analysis/src/check/compare_eii.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ use std::borrow::Cow;
22
use std::iter;
33

44
use rustc_data_structures::fx::FxIndexSet;
5-
use rustc_errors::{
6-
Applicability, Applicability, E0053, E0053, struct_span_code_err, struct_span_code_err,
7-
};
5+
use rustc_errors::{Applicability, E0053, E0053, struct_span_code_err, struct_span_code_err};
86
use rustc_hir::def_id::{DefId, LocalDefId};
97
use rustc_hir::{self as hir, self as hir, HirId, HirId, ItemKind, ItemKind};
108
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
119
use rustc_infer::traits::{ObligationCause, ObligationCauseCode};
1210
use rustc_middle::ty;
1311
use rustc_middle::ty::TyCtxt;
14-
use rustc_middle::ty::error::{ExpectedFound, ExpectedFound, TypeError, TypeError};
12+
use rustc_middle::ty::error::{ExpectedFound, TypeError, TypeError};
1513
use rustc_span::{ErrorGuaranteed, Ident, Span};
1614
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1715
use rustc_trait_selection::regions::InferCtxtRegionExt;
@@ -54,11 +52,13 @@ pub(crate) fn compare_eii_function_types<'tcx>(
5452
// type.
5553

5654
let wf_tys = FxIndexSet::default();
57-
5855
let external_impl_sig = infcx.instantiate_binder_with_fresh_vars(
5956
external_impl_span,
6057
infer::HigherRankedType,
61-
tcx.fn_sig(external_impl).instantiate_identity(),
58+
tcx.fn_sig(external_impl).instantiate(
59+
tcx,
60+
infcx.fresh_args_for_item(external_impl_span, external_impl.to_def_id()),
61+
),
6262
);
6363

6464
let norm_cause = ObligationCause::misc(external_impl_span, external_impl);

compiler/rustc_resolve/src/ident.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
294294
ribs: &[Rib<'ra>],
295295
ignore_binding: Option<NameBinding<'ra>>,
296296
) -> Option<LexicalScopeBinding<'ra>> {
297-
assert!(ns == TypeNS || ns == ValueNS);
298297
let orig_ident = ident;
299298
let (general_span, normalized_span) = if ident.name == kw::SelfUpper {
300299
// FIXME(jseyfried) improve `Self` hygiene
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(eii)]
2+
#![feature(decl_macro)]
3+
#![feature(rustc_attrs)]
4+
#![feature(eii_internals)]
5+
6+
#[core::eii_macro_for(bar)]
7+
#[rustc_builtin_macro(eii_macro)]
8+
pub macro foo() {
9+
10+
}
11+
12+
unsafe extern "Rust" {
13+
pub safe fn bar(x: u64) -> u64;
14+
}

tests/ui/eii/cross_crate.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: --crate-type rlib
2+
//@ check-pass
3+
//@ aux-build: cross_crate_eii_declaration.rs
4+
#![feature(eii)]
5+
#![feature(decl_macro)]
6+
#![feature(rustc_attrs)]
7+
#![feature(eii_internals)]
8+
9+
extern crate cross_crate_eii_declaration;
10+
11+
#[unsafe(cross_crate_eii_declaration::foo)]
12+
fn other(x: u64) -> u64 {
13+
x
14+
}
15+
16+
fn main() {
17+
cross_crate_eii_declaration::bar(0);
18+
}

tests/ui/eii/subtype_1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ compile-flags: --crate-type rlib
2-
//@ check-pass
32
#![feature(eii)]
43
#![feature(decl_macro)]
54
#![feature(rustc_attrs)]

tests/ui/eii/subtype_3.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ compile-flags: --crate-type rlib
2+
//@ check-pass
3+
#![feature(eii)]
4+
#![feature(decl_macro)]
5+
#![feature(rustc_attrs)]
6+
#![feature(eii_internals)]
7+
8+
#[core::eii_macro_for(bar)]
9+
#[rustc_builtin_macro(eii_macro)]
10+
macro foo() {
11+
12+
}
13+
14+
unsafe extern "Rust" {
15+
safe fn bar<'a>(x: &'a u64) -> &'a u64;
16+
}
17+
18+
#[foo]
19+
fn other<'a>(x: &'a u64) -> &'static u64 {
20+
&0
21+
}
22+
23+
fn main() {
24+
bar(&0);
25+
}

tests/ui/eii/subtype_4.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ compile-flags: --crate-type rlib
2+
//@ check-pass
3+
#![feature(eii)]
4+
#![feature(decl_macro)]
5+
#![feature(rustc_attrs)]
6+
#![feature(eii_internals)]
7+
8+
#[core::eii_macro_for(bar)]
9+
#[rustc_builtin_macro(eii_macro)]
10+
macro foo() {
11+
12+
}
13+
14+
unsafe extern "Rust" {
15+
safe fn bar(x: u64) -> u64;
16+
}
17+
18+
#[foo]
19+
fn other(x: u64) -> u64 {
20+
x
21+
}
22+
23+
fn main() {
24+
bar(0);
25+
}

tests/ui/eii/wrong_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ unsafe extern "Rust" {
1515
}
1616

1717
#[foo]
18-
fn other() -> u64 {
18+
fn other(x: usize) -> u64 {
1919
//~^ ERROR function `other` has a type that is incompatible with the declaration
2020
3
2121
}

tests/ui/eii/wrong_ty.stderr

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
error[E0053]: function `other` has a type that is incompatible with the declaration
2-
--> $DIR/wrong_ty.rs:18:1
2+
--> $DIR/wrong_ty.rs:18:13
33
|
4-
LL | fn other() -> u64 {
5-
| ^^^^^^^^^^^^^^^^^ incorrect number of function parameters
4+
LL | fn other(x: usize) -> u64 {
5+
| ^^^^^ expected `u64`, found `usize`
66
|
77
note: type in declaration
8-
--> $DIR/wrong_ty.rs:14:5
8+
--> $DIR/wrong_ty.rs:14:20
99
|
1010
LL | safe fn bar(x: u64) -> u64;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
| ^^^
1212
= note: expected signature `fn(u64) -> _`
13-
found signature `fn() -> _`
13+
found signature `fn(usize) -> _`
14+
help: change the parameter type to match the declaration
15+
|
16+
LL - fn other(x: usize) -> u64 {
17+
LL + fn other(x: u64) -> u64 {
18+
|
1419

1520
error: aborting due to 1 previous error
1621

tests/ui/eii/wrong_ty_2.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ compile-flags: --crate-type rlib
2+
#![feature(eii)]
3+
#![feature(decl_macro)]
4+
#![feature(rustc_attrs)]
5+
#![feature(eii_internals)]
6+
7+
#[core::eii_macro_for(bar)]
8+
#[rustc_builtin_macro(eii_macro)]
9+
macro foo() {
10+
11+
}
12+
13+
unsafe extern "Rust" {
14+
safe fn bar(x: u64) -> u64;
15+
}
16+
17+
#[foo]
18+
fn other() -> u64 {
19+
//~^ ERROR function `other` has a type that is incompatible with the declaration
20+
3
21+
}
22+
23+
fn main() {
24+
bar(0);
25+
}

tests/ui/eii/wrong_ty_2.stderr

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0053]: function `other` has a type that is incompatible with the declaration
2+
--> $DIR/wrong_ty_2.rs:18:1
3+
|
4+
LL | fn other() -> u64 {
5+
| ^^^^^^^^^^^^^^^^^ incorrect number of function parameters
6+
|
7+
note: type in declaration
8+
--> $DIR/wrong_ty_2.rs:14:5
9+
|
10+
LL | safe fn bar(x: u64) -> u64;
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= note: expected signature `fn(u64) -> _`
13+
found signature `fn() -> _`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0053`.

0 commit comments

Comments
 (0)